1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-03 01:39:28 +02:00

Use ready macro to reduce boilerplate

This commit is contained in:
johannesd3 2021-04-17 11:55:57 +02:00
parent 4fc3accc78
commit 7d6267c0a2
No known key found for this signature in database
GPG key ID: 8C2739E91D410F75
3 changed files with 16 additions and 47 deletions

View file

@ -7,6 +7,7 @@ use std::task::Poll;
use byteorder::{BigEndian, ByteOrder};
use bytes::Bytes;
use futures_util::FutureExt;
use tokio::sync::{mpsc, oneshot};
use crate::protocol;
@ -41,11 +42,7 @@ impl<T> Future for MercuryFuture<T> {
type Output = Result<T, MercuryError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match Pin::new(&mut self.receiver).poll(cx) {
Poll::Ready(Ok(x)) => Poll::Ready(x),
Poll::Ready(Err(_)) => Poll::Ready(Err(MercuryError)),
Poll::Pending => Poll::Pending,
}
self.receiver.poll_unpin(cx).map_err(|_| MercuryError)?
}
}