benkay86 / nom-tutorial

Tutorial for parsing with nom 5.
288 stars 17 forks source link

References to removed ParseError in tutorial #9

Closed Brian-Williams closed 2 years ago

Brian-Williams commented 4 years ago

The tutorial references the ParseError, which was removed in commit 34cd46621333971a05f28ce22b7edb18baa31ba3 https://github.com/benkay86/nom-tutorial/blame/master/README.md#L551.

I was able to get it working with the following, but don't think it's a great solution as it's incompatible with the src version:

pub fn mounts() -> Result<(), Box<dyn Error>> {
    let file = std::fs::File::open("/proc/mounts")?;
    let buf_reader = std::io::BufReader::new(file);
    for line in buf_reader.lines() {
        match parsers::parse_line(&line?[..]) {
            Ok( (_, m) ) => {
                println!("{}", m);
            },
            Err(e) => return Err(e.to_owned().into())
        }
    }
    Ok(())
}
Brian-Williams commented 2 years ago

Closing as no longer maintained