Fix failing test
This commit is contained in:
parent
7915732714
commit
e449f3d629
1 changed files with 7 additions and 6 deletions
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue