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 ;
12use core:: iter:: * ;
23use core:: { i8, i16, isize} ;
34use core:: usize;
@@ -1908,19 +1909,19 @@ fn test_once() {
19081909
19091910#[ test]
19101911fn 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]
You can’t perform that action at this time.
0 commit comments