@@ -19,7 +19,7 @@ fn main_0() -> i32 {
1919 } ) ) ) ;
2020 assert ! ( ( ( { ( * zero. borrow( ) ) . call( ) } ) == 42 ) ) ;
2121 let one: Value < FnPtr < fn ( i32 ) -> i32 > > = Rc :: new ( RefCell :: new ( FnPtr :: < fn ( i32 ) -> i32 > :: new (
22- |x : i32 | -> i32 {
22+ |mut x : i32 | -> i32 {
2323 {
2424 return ( x + 1 ) ;
2525 }
@@ -28,7 +28,7 @@ fn main_0() -> i32 {
2828 assert ! ( ( ( { ( * one. borrow( ) ) . call( 1 , ) } ) == 2 ) ) ;
2929 let three: Value < FnPtr < fn ( i32 , i32 , i32 ) -> i32 > > =
3030 Rc :: new ( RefCell :: new ( FnPtr :: < fn ( i32 , i32 , i32 ) -> i32 > :: new (
31- |x : i32 , y : i32 , z : i32 | -> i32 {
31+ |mut x : i32 , mut y : i32 , mut z : i32 | -> i32 {
3232 {
3333 return ( ( ( x * 100 ) + ( y * 10 ) ) + z) ;
3434 }
@@ -38,7 +38,7 @@ fn main_0() -> i32 {
3838 let mut k: i32 = 3 ;
3939 let mut m: i32 = 4 ;
4040 let constants: Value < FnPtr < fn ( i32 ) -> i32 > > = Rc :: new ( RefCell :: new (
41- FnPtr :: < fn ( i32 ) -> i32 > :: new ( |x : i32 | -> i32 {
41+ FnPtr :: < fn ( i32 ) -> i32 > :: new ( |mut x : i32 | -> i32 {
4242 {
4343 return ( ( x + 3 ) + 4 ) ;
4444 }
@@ -47,21 +47,46 @@ fn main_0() -> i32 {
4747 assert ! ( ( ( { ( * constants. borrow( ) ) . call( 1 , ) } ) == 8 ) ) ;
4848 let mut n: i32 = ( k + m) ;
4949 let derived: Value < FnPtr < fn ( i32 ) -> i32 > > = Rc :: new ( RefCell :: new (
50- FnPtr :: < fn ( i32 ) -> i32 > :: new ( |x : i32 | -> i32 {
50+ FnPtr :: < fn ( i32 ) -> i32 > :: new ( |mut x : i32 | -> i32 {
5151 {
5252 return ( x + ( 3 + 4 ) ) ;
5353 }
5454 } ) ,
5555 ) ) ;
5656 assert ! ( ( ( { ( * derived. borrow( ) ) . call( 1 , ) } ) == 8 ) ) ;
5757 let implicit: Value < FnPtr < fn ( i32 ) -> i32 > > = Rc :: new ( RefCell :: new (
58- FnPtr :: < fn ( i32 ) -> i32 > :: new ( |x : i32 | -> i32 {
58+ FnPtr :: < fn ( i32 ) -> i32 > :: new ( |mut x : i32 | -> i32 {
5959 {
6060 return ( x + 3 ) ;
6161 }
6262 } ) ,
6363 ) ) ;
6464 assert ! ( ( ( { ( * implicit. borrow( ) ) . call( 1 , ) } ) == 4 ) ) ;
65+ let bump: Value < FnPtr < fn ( i32 ) -> i32 > > = Rc :: new ( RefCell :: new ( FnPtr :: < fn ( i32 ) -> i32 > :: new (
66+ |mut x : i32 | -> i32 {
67+ {
68+ x += 1 ;
69+ return x;
70+ }
71+ } ,
72+ ) ) ) ;
73+ assert ! ( ( ( { ( * bump. borrow( ) ) . call( 1 , ) } ) == 2 ) ) ;
74+ let through_ptr: Value < FnPtr < fn ( i32 ) -> i32 > > = Rc :: new ( RefCell :: new (
75+ FnPtr :: < fn ( i32 ) -> i32 > :: new ( |x : i32 | -> i32 {
76+ {
77+ let x: Value < i32 > = Rc :: new ( RefCell :: new ( x) ) ;
78+ let mut p: Ptr < i32 > = ( x. as_pointer ( ) ) ;
79+ p. write ( { ( ( p. read ( ) ) * 2 ) } ) ;
80+ return ( * x. borrow ( ) ) ;
81+ }
82+ } ) ,
83+ ) ) ;
84+ assert ! ( ( ( { ( * through_ptr. borrow( ) ) . call( 4 , ) } ) == 8 ) ) ;
85+ let mut seed: i32 = 5 ;
86+ let boxed: Value < i32 > = Rc :: new ( RefCell :: new ( ( { ( * through_ptr. borrow ( ) ) . call ( seed) } ) ) ) ;
87+ let mut boxed_ptr: Ptr < i32 > = ( boxed. as_pointer ( ) ) ;
88+ assert ! ( ( ( boxed_ptr. read( ) ) == 10 ) ) ;
89+ assert ! ( ( seed == 5 ) ) ;
6590 return 0 ;
6691}
6792pub fn __cpp2rust_init_globals ( ) { }
0 commit comments