diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-06 10:05:11 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-06 10:05:11 +0200 |
| commit | bfaf5447a789cd0dbbb1e418bea62fef9edc2b7d (patch) | |
| tree | 0cc1a47b37439fbeda06c57ebef0025becae0066 /src/eval/args.rs | |
| parent | 49b8574b8d03e52a990f7d7b009c36fbdad0d55a (diff) | |
Cast content from string
Diffstat (limited to 'src/eval/args.rs')
| -rw-r--r-- | src/eval/args.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/eval/args.rs b/src/eval/args.rs index f507e714..9b21cfa2 100644 --- a/src/eval/args.rs +++ b/src/eval/args.rs @@ -44,20 +44,6 @@ impl Args { Self { span, items } } - /// Consume and cast the first positional argument. - /// - /// Returns a `missing argument: {what}` error if no positional argument is - /// left. - pub fn expect<T>(&mut self, what: &str) -> TypResult<T> - where - T: Cast<Spanned<Value>>, - { - match self.eat()? { - Some(v) => Ok(v), - None => bail!(self.span, "missing argument: {}", what), - } - } - /// Consume and cast the first positional argument if there is one. pub fn eat<T>(&mut self) -> TypResult<Option<T>> where @@ -73,6 +59,20 @@ impl Args { Ok(None) } + /// Consume and cast the first positional argument. + /// + /// Returns a `missing argument: {what}` error if no positional argument is + /// left. + pub fn expect<T>(&mut self, what: &str) -> TypResult<T> + where + T: Cast<Spanned<Value>>, + { + match self.eat()? { + Some(v) => Ok(v), + None => bail!(self.span, "missing argument: {}", what), + } + } + /// Find and consume the first castable positional argument. pub fn find<T>(&mut self) -> TypResult<Option<T>> where |
