Add a repeat function to the prelude
Implements a part of RFC 235. [breaking-change]
This commit is contained in:
@@ -846,6 +846,14 @@ fn test_iterate() {
|
||||
assert_eq!(it.next(), Some(8u));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_repeat() {
|
||||
let mut it = repeat(42u);
|
||||
assert_eq!(it.next(), Some(42u));
|
||||
assert_eq!(it.next(), Some(42u));
|
||||
assert_eq!(it.next(), Some(42u));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_rposition(b: &mut Bencher) {
|
||||
let it: Vec<uint> = range(0u, 300).collect();
|
||||
|
||||
Reference in New Issue
Block a user