Skip to content

Instantly share code, notes, and snippets.

@Thiez
Created May 16, 2013 19:24
Show Gist options
  • Save Thiez/5594335 to your computer and use it in GitHub Desktop.
Save Thiez/5594335 to your computer and use it in GitHub Desktop.
Copy of a test from libcore/iterator.rs that somehow can't compile.
use core::iterator::UnfoldrIterator;
fn test_unfoldr() {
fn count(st: &mut uint) -> Option<uint> {
if *st < 10 {
let ret = Some(*st);
*st += 1;
ret
} else {
None
}
}
let mut it = UnfoldrIterator::new(count, 0);
let mut i = 0;
for it.advance |counted| {
assert_eq!(counted, i);
i += 1;
}
assert_eq!(i, 10);
}
fn main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment