/// Take an item from a stream the produces results and return an `Option<T>` when available.
/// Log a message including the `stream_name` when the stream produces an error or is exhausted.
///
/// This is useful when dealing with streams where the only meaningful difference between
/// a terminated stream and an error value is how it should be logged.
Take an item from a stream the produces results and return an `Option` when available.
Log a message including the `stream_name` when the stream produces an error or is exhausted.

This is useful when dealing with streams where the only meaningful difference between
a terminated stream and an error value is how it should be logged.
Take an item from a stream the produces results and return an ` Option ` when available . Log a message including the ` stream_name ` when the stream produces an error or is exhausted . This is useful when dealing with streams where the only meaningful difference between a terminated stream and an error value is how it should be logged .
fn stream_item_map_or_log<T, E: fmt::Debug>(
    item: Option<Result<T, E>>,
    stream_name: &str,
    peer_id: &PeerId,
) -> Option<T> {
    match item {
        Some(Ok(value)) => Some(value),
        Some(Err(e)) => {
            warn!("Error on stream {} for peer {:}: {:?}", stream_name, peer_id, e);
            None
        }
        None => {
            info!("Stream {} closed for peer {:}", stream_name, peer_id);
            None
        }
    }
}
fn stream_item_map_or_log < T , E : fmt :: Debug > ( item : Option < Result < T , E > > , stream_name : & str , peer_id : & PeerId , ) -> Option < T > { match item { Some ( Ok ( value ) ) => Some ( value ) , Some ( Err ( e ) ) => { warn ! ( " " stream_name peer_id e ) ; None } None => { info ! ( " " stream_name peer_id ) ; None } } }
Take an item from a stream the produces results and return an `Option<T>` when available.
Take an item from a stream the produces results and return an ` Option<T > ` when available .
item
Option<Result<T, E>>
stream_name
&str
peer_id
&PeerId