macro_rules! try_scan {
($pattern:expr, $($arg:expr),*) => { ... };
($input:expr => $pattern:expr, $($arg:expr),*) => { ... };
(@question_mark: $($e:tt)+) => { ... };
(@unwrap: $($e:tt)+) => { ... };
(@impl $action:tt; $input:expr => $pattern:expr, $($arg:expr),*) => { ... };
}
Expand description
use text_io::try_scan;
fn parser() -> Result<i32, Box<dyn std::error::Error>> {
let i: i32;
let text = "The answer is 42!";
try_scan!(text.bytes() => "The answer is {}!", i);
assert_eq!(i, 1);
Ok(i)
}