rust-bakery / nom

Rust parser combinator framework
MIT License
9.18k stars 792 forks source link

FromStr-esque parsing trait #1724

Open JamieH01 opened 5 months ago

JamieH01 commented 5 months ago

I think a simple FromStr-esque trait would be useful to have for organization and possibly some combinators. I use FromStr a lot since its very good for small composable types providing their parsers, and a nom-ified trait for this would be a nice addition.

pub trait Parsable<O>: Sized {
    type Err;
    fn parse(s: O) -> IResult<Self, O, Self::Err>; 
}
JamieH01 commented 5 months ago

went ahead and made a pr: #1726