From bfaf5447a789cd0dbbb1e418bea62fef9edc2b7d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 6 May 2022 10:05:11 +0200 Subject: Cast content from string --- src/eval/args.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/eval/args.rs') 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(&mut self, what: &str) -> TypResult - where - T: Cast>, - { - 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(&mut self) -> TypResult> 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(&mut self, what: &str) -> TypResult + where + T: Cast>, + { + 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(&mut self) -> TypResult> where -- cgit v1.2.3