home ~ projects ~ socials

Check For nom tag() Matches In A Vec In Rust

This is what I'm using in Neopoligen to check to see if a tag matches one of the configured tags that's stored in a BTreeMap.

TODO: Edit this down so it's a more direct and full example with a Vec.

let (source, kind) = site_config
    .section_types
    .get("checklist")
    .unwrap()
    .iter()
    .fold(fail(source), |acc, item| match acc {
        Ok(v) => Ok(v),
        Err(_) => tag(item.as_str()).context("").parse(source),
    })?;
-- end of line --