Skip to content

Commit e449f3d

Browse files
author
Stjepan Glavina
committed
Fix failing test
1 parent 7915732 commit e449f3d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/libcore/tests/iter.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use core::cell::Cell;
12
use core::iter::*;
23
use core::{i8, i16, isize};
34
use core::usize;
@@ -1908,19 +1909,19 @@ fn test_once() {
19081909

19091910
#[test]
19101911
fn test_once_with() {
1911-
let mut count = 0;
1912+
let mut count = Cell::new(0);
19121913
let mut it = once_with(|| {
1913-
count += 1;
1914+
count.set(count.get() + 1);
19141915
42
19151916
});
19161917

1917-
assert_eq!(count, 0);
1918+
assert_eq!(count.get(), 0);
19181919
assert_eq!(it.next(), Some(42));
1919-
assert_eq!(count, 1);
1920+
assert_eq!(count.get(), 1);
19201921
assert_eq!(it.next(), None);
1921-
assert_eq!(count, 1);
1922+
assert_eq!(count.get(), 1);
19221923
assert_eq!(it.next(), None);
1923-
assert_eq!(count, 1);
1924+
assert_eq!(count.get(), 1);
19241925
}
19251926

19261927
#[test]

0 commit comments

Comments
 (0)