Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

[] Look at this :

rust
tuple((opt(tag::<&str, &str, nom::error::Error<&str>>("data-")), is_not(":"), tag(": "), not_line_ending))

This is for when you don't want to have the error automatically float up in a way that requires making the functions return an IResult. This helps where it won't let you use a value because it's owned by a function that would make it disappear when the function is finished.

rust
use nom::bytes::complete::tag;
use nom::error::Error;

#[derive(Debug)]
struct Widget {
    text: String,
}

fn main() {
    let mut w = Widget {
        text: "the quick brown fox".to_string(),
    };
    parse(&mut w);
    dbg!(w);
}

fn parse(w: &mut Widget) {
    let response = tag::<&str, &str, Error<&str>>("the quick ")(w.text.as_str()).unwrap();
    w.text = response.0.to_string();
}

- I'm not sure what the error types are and they should probably be handled better.

Working with nom without the [TODO: Code shorthand span ] method