Fix failing test

This commit is contained in:
Stjepan Glavina
2019-01-14 00:45:57 +01:00
parent 7915732714
commit e449f3d629
+7 -6
View File
@@ -1,3 +1,4 @@
use core::cell::Cell;
use core::iter::*;
use core::{i8, i16, isize};
use core::usize;
@@ -1908,19 +1909,19 @@ fn test_once() {
#[test]
fn test_once_with() {
let mut count = 0;
let mut count = Cell::new(0);
let mut it = once_with(|| {
count += 1;
count.set(count.get() + 1);
42
});
assert_eq!(count, 0);
assert_eq!(count.get(), 0);
assert_eq!(it.next(), Some(42));
assert_eq!(count, 1);
assert_eq!(count.get(), 1);
assert_eq!(it.next(), None);
assert_eq!(count, 1);
assert_eq!(count.get(), 1);
assert_eq!(it.next(), None);
assert_eq!(count, 1);
assert_eq!(count.get(), 1);
}
#[test]