diff options
Diffstat (limited to 'crates/parseable')
| -rw-r--r-- | crates/parseable/Cargo.toml | 7 | ||||
| -rw-r--r-- | crates/parseable/src/lib.rs | 18 |
2 files changed, 25 insertions, 0 deletions
diff --git a/crates/parseable/Cargo.toml b/crates/parseable/Cargo.toml new file mode 100644 index 0000000..25b0c77 --- /dev/null +++ b/crates/parseable/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "parseable" +version = "0.1.0" +edition = "2024" + +[dependencies] +mon = { workspace = true }
\ No newline at end of file diff --git a/crates/parseable/src/lib.rs b/crates/parseable/src/lib.rs new file mode 100644 index 0000000..38ed418 --- /dev/null +++ b/crates/parseable/src/lib.rs @@ -0,0 +1,18 @@ +#![feature(impl_trait_in_assoc_type)] + +use mon::{Parser, input::{Input, InputIter}}; + +pub trait Parseable<'a, I: Input + 'a> { + type Parser: Parser<I, Output = Self>; + + fn parser() -> Self::Parser; + + fn parse(input: I) -> Result<Self, I> + where + Self: Sized, + { + Self::parser() + .parse_finished(InputIter::new(input)) + .map_err(|e| e.rest()) + } +} |
