summaryrefslogtreecommitdiff
path: root/crates/parseable
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-12-17 06:45:27 +0000
committerJohn Turner <jturner.usa@gmail.com>2025-12-17 06:45:27 +0000
commitc63c3e8c8c73ed7c036df7511ca190cdb96d92e2 (patch)
tree3262ef318f03388d37ac28493e42c1638c227c27 /crates/parseable
parent0ec856797256b5d9807929e1b32c03756eb43124 (diff)
downloadgentoo-utils-split-into-workspace.tar.gz
Diffstat (limited to 'crates/parseable')
-rw-r--r--crates/parseable/Cargo.toml7
-rw-r--r--crates/parseable/src/lib.rs18
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())
+ }
+}