Implement RFC 771: std::iter::once

This commit is contained in:
Nathaniel Theis
2015-05-26 16:39:18 -07:00
parent 2d447e40e2
commit 103e79d26a
3 changed files with 109 additions and 0 deletions

View File

@@ -1096,6 +1096,19 @@ fn test_fuse_count() {
// Can't check len now because count consumes.
}
#[test]
fn test_once() {
let mut it = once(42);
assert_eq!(it.next(), Some(42));
assert_eq!(it.next(), None);
}
#[test]
fn test_empty() {
let mut it = empty::<i32>();
assert_eq!(it.next(), None);
}
#[bench]
fn bench_rposition(b: &mut Bencher) {
let it: Vec<usize> = (0..300).collect();

View File

@@ -25,6 +25,8 @@
#![feature(slice_patterns)]
#![feature(float_from_str_radix)]
#![feature(cell_extras)]
#![feature(iter_empty)]
#![feature(iter_once)]
extern crate core;
extern crate test;