diff options
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 |
