Created
May 16, 2013 19:24
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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