fn process_file()

in smt2parser/src/main.rs [61:79]


fn process_file<T, F>(state: T, file_path: PathBuf, mut f: F) -> std::io::Result<T>
where
    T: smt2parser::visitors::Smt2Visitor,
    F: FnMut(T::Command),
    T::Error: std::fmt::Display,
{
    let file = std::io::BufReader::new(std::fs::File::open(&file_path)?);
    let mut stream = CommandStream::new(file, state, file_path.to_str().map(String::from));
    for result in &mut stream {
        match result {
            Ok(command) => f(command),
            Err(error) => {
                eprintln!("{}", error);
                break;
            }
        }
    }
    Ok(stream.into_visitor())
}