stream: implement Error and Display for BroadcastStreamRecvError (#3745)

This commit is contained in:
Chế Vũ Gia Hy
2021-05-05 11:15:42 +02:00
committed by GitHub
parent 14bb2f624f
commit a945ce0996
+10
View File
@@ -27,6 +27,16 @@ pub enum BroadcastStreamRecvError {
Lagged(u64),
}
impl fmt::Display for BroadcastStreamRecvError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
BroadcastStreamRecvError::Lagged(amt) => write!(f, "channel lagged by {}", amt),
}
}
}
impl std::error::Error for BroadcastStreamRecvError {}
async fn make_future<T: Clone>(mut rx: Receiver<T>) -> (Result<T, RecvError>, Receiver<T>) {
let result = rx.recv().await;
(result, rx)