diff options
Diffstat (limited to 'rust/graph/unfold.rs')
-rw-r--r-- | rust/graph/unfold.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/rust/graph/unfold.rs b/rust/graph/unfold.rs new file mode 100644 index 0000000..90de74c --- /dev/null +++ b/rust/graph/unfold.rs @@ -0,0 +1,16 @@ +extern crate itertools; + +use itertools::Unfold; + +fn main() { + for n in Unfold::new(1, |state| { + if *state < 100 { + *state += 1; + Some(*state) + } else { + None + } + }) { + println!("{}", n); + } +} |