/// Simple helper to send all available lines through a sender AND
/// clears the underlying line buffer; It sends the last unfinished line if any.
Simple helper to send all available lines through a sender AND
clears the underlying line buffer; It sends the last unfinished line if any.
Simple helper to send all available lines through a sender AND clears the underlying line buffer ; It sends the last unfinished line if any .
pub fn send_lines_through_and_clear<E>(
    logger: &Logger,
    snd: &Sender<E>,
    str2e: impl Fn(String) -> E,
    lb: &mut LineBuffer,
) {
    while let Some(line) = lb.read_line() {
        if let Err(e) = snd.send(str2e(line)) {
            warn!(logger, "Couldn't send: {:?}", e);
        }
    }
    let last = lb.clear();
    if !last.is_empty() {
        if let Err(e) = snd.send(str2e(last)) {
            warn!(logger, "Couldn't send: {:?}", e);
        }
    }
}
pub fn send_lines_through_and_clear < E > ( logger : & Logger , snd : & Sender < E > , str2e : impl Fn ( String ) -> E , lb : & mut LineBuffer , ) { while let Some ( line ) = lb . read_line ( ) { if let Err ( e ) = snd . send ( str2e ( line ) ) { warn ! ( logger " " e ) ; } } let last = lb . clear ( ) ; if ! last . is_empty ( ) { if let Err ( e ) = snd . send ( str2e ( last ) ) { warn ! ( logger " " e ) ; } } }
Simple helper to send all available lines through a sender AND
clears the underlying line buffer; It sends the last unfinished line if any.
Simple helper to send all available lines through a sender AND clears the underlying line buffer ; It sends the last unfinished line if any .
logger
&Logger
snd
&Sender<E>
str2e
impl Fn(String) -> E
lb
&mut LineBuffer