@@ -4,14 +4,19 @@ use crate::Result;
|
||||
|
||||
pub trait TryExpect<'a, Item> {
|
||||
fn expect_ok(self) -> impl Stream<Item = Item> + Send + 'a;
|
||||
|
||||
fn map_expect(self, msg: &'a str) -> impl Stream<Item = Item> + Send + 'a;
|
||||
}
|
||||
|
||||
impl<'a, T, Item> TryExpect<'a, Item> for T
|
||||
where
|
||||
T: Stream<Item = Result<Item>> + TryStream + Send + 'a,
|
||||
Item: 'a,
|
||||
{
|
||||
#[inline]
|
||||
fn expect_ok(self: T) -> impl Stream<Item = Item> + Send + 'a {
|
||||
self.map(|res| res.expect("stream expectation failure"))
|
||||
}
|
||||
fn expect_ok(self: T) -> impl Stream<Item = Item> + Send + 'a { self.map_expect("stream expectation failure") }
|
||||
|
||||
//TODO: move to impl MapExpect
|
||||
#[inline]
|
||||
fn map_expect(self, msg: &'a str) -> impl Stream<Item = Item> + Send + 'a { self.map(|res| res.expect(msg)) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user