Add a repeat function to the prelude

Implements a part of RFC 235.

[breaking-change]
This commit is contained in:
Jakub Bukaj
2014-10-30 23:44:42 +01:00
parent 52c3fe9533
commit 696f72e84e
4 changed files with 16 additions and 3 deletions

View File

@@ -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();