diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-01-24 12:44:04 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-01-24 12:44:04 +0100 |
| commit | 03fddaf3aea778057aedd74dbcb27bae971ec22f (patch) | |
| tree | 37e3136e29e0e5d69ec8f56e43d156739d2931ab /src/func/mod.rs | |
| parent | 78da2bdd5d77d1b8572e5e9da119bfa68127a3fa (diff) | |
Non-fatal argument parsing 🌋
Diffstat (limited to 'src/func/mod.rs')
| -rw-r--r-- | src/func/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/func/mod.rs b/src/func/mod.rs index e3399903..b3721d91 100644 --- a/src/func/mod.rs +++ b/src/func/mod.rs @@ -26,7 +26,7 @@ pub trait Parse { /// Parse the header and body into this function given a context. fn parse( header: FuncHeader, - body: Option<(Position, &str)>, + body: Option<Spanned<&str>>, ctx: ParseContext, metadata: Self::Meta, ) -> Parsed<Self> where Self: Sized; @@ -36,7 +36,7 @@ pub trait Parse { /// implements [`Model`]. type Parser = dyn Fn( FuncHeader, - Option<(Position, &str)>, + Option<Spanned<&str>>, ParseContext, ) -> Parsed<Box<dyn Model>>; @@ -50,7 +50,7 @@ pub enum Command<'a> { Add(Layout), AddMultiple(MultiLayout), - SpacingFunc(Size, SpacingKind, GenericAxis), + AddSpacing(Size, SpacingKind, GenericAxis), FinishLine, FinishSpace, @@ -88,12 +88,12 @@ impl Scope { /// Associate the given name with a type that is parseable into a function. pub fn add<F>(&mut self, name: &str) where F: Parse<Meta=()> + Model + 'static { - self.add_with_metadata::<F>(name, ()); + self.add_with_meta::<F>(name, ()); } /// Add a parseable type with additional metadata that is given to the /// parser (other than the default of `()`). - pub fn add_with_metadata<F>(&mut self, name: &str, metadata: <F as Parse>::Meta) + pub fn add_with_meta<F>(&mut self, name: &str, metadata: <F as Parse>::Meta) where F: Parse + Model + 'static { self.parsers.insert( name.to_owned(), |
