[][src]Function shellac_codec::read_reply

pub fn read_reply<R, T, E, F>(reader: &mut R, f: F) -> Result<T, E> where
    E: From<Error> + From<NotInSchema>,
    R: BufRead,
    F: FnOnce(Map<ListIter<Reader<'a, Owned>, Reader<'a>>, fn(_: Reader<'a>) -> Result<(SuggestionType<&'a str>, &'a str), E>>) -> Result<T, E>, 

Read a ShellAC Server reply without (necessarily) collecting.

use std::io::{self, BufReader};

shellac::read_reply::<_, _, shellac::Error, _>(&mut BufReader::new(io::stdin()), |suggestions| {
    for (suggestion, description) in suggestions.map(Result::unwrap) {
        println!("Suggestion: '{:?}' ({})", suggestion, description);
    }
    Ok(())
});