File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change
1
+ use core:: cell:: Cell ;
1
2
use core:: iter:: * ;
2
3
use core:: { i8, i16, isize} ;
3
4
use core:: usize;
@@ -1908,19 +1909,19 @@ fn test_once() {
1908
1909
1909
1910
#[ test]
1910
1911
fn test_once_with ( ) {
1911
- let mut count = 0 ;
1912
+ let mut count = Cell :: new ( 0 ) ;
1912
1913
let mut it = once_with ( || {
1913
- count += 1 ;
1914
+ count. set ( count . get ( ) + 1 ) ;
1914
1915
42
1915
1916
} ) ;
1916
1917
1917
- assert_eq ! ( count, 0 ) ;
1918
+ assert_eq ! ( count. get ( ) , 0 ) ;
1918
1919
assert_eq ! ( it. next( ) , Some ( 42 ) ) ;
1919
- assert_eq ! ( count, 1 ) ;
1920
+ assert_eq ! ( count. get ( ) , 1 ) ;
1920
1921
assert_eq ! ( it. next( ) , None ) ;
1921
- assert_eq ! ( count, 1 ) ;
1922
+ assert_eq ! ( count. get ( ) , 1 ) ;
1922
1923
assert_eq ! ( it. next( ) , None ) ;
1923
- assert_eq ! ( count, 1 ) ;
1924
+ assert_eq ! ( count. get ( ) , 1 ) ;
1924
1925
}
1925
1926
1926
1927
#[ test]
You can’t perform that action at this time.
0 commit comments