mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
15 lines
254 B
Rust
15 lines
254 B
Rust
//@ check-pass
|
|
|
|
fn fibs(n: u32) -> impl Iterator<Item=u128> {
|
|
(0 .. n)
|
|
.scan((0, 1), |st, _| {
|
|
*st = (st.1, st.0 + st.1);
|
|
Some(*st)
|
|
})
|
|
.map(&|(f, _)| f)
|
|
}
|
|
|
|
fn main() {
|
|
println!("{:?}", fibs(10).collect::<Vec<_>>());
|
|
}
|