Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. use futures::{Future, Stream}; // 0.1.28
  2.  
  3. pub fn take_first<S>(stream: S) -> impl Future<Item = Option<S::Item>, Error = S::Error>
  4. where
  5. S: Stream,
  6. {
  7. stream
  8. .into_future()
  9. .map(|(maybe_first, _rest_of_the_stream)| maybe_first)
  10. .map_err(|(err, _rest_of_the_stream)| err)
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement