macro
5 years ago in Rust
macro_rules! recurrence {
( a[n] = $($inits:expr),+ , ... , $recur:expr ) => {
/* ... */
};
}
fn main() {
let fib = recurrence![a[n] = 0, 1, ..., a[n-1] + a[n-2]];
for (i, e) in fib.enumerate().take(10) {
println!("{} {}", i, e)
}
}
/*
error: local ambiguity: multiple parsing options: built-in NTs expr ('inits') or 1 other option.
--> src/main.rs:8:40
|
8 | let fib = recurrence![a[n] = 0, 1, ..., a[n-1] + a[n-2]];
| ^^^
*/