@@ -54,11 +54,39 @@ pub fn negate_1(x: i32) -> i32 {
5454 let x: Value < i32 > = Rc :: new ( RefCell :: new ( x) ) ;
5555 return -( * x. borrow ( ) ) ;
5656}
57+ #[ derive( Clone , ByteRepr , Default ) ]
58+ pub struct S { }
59+ impl S {
60+ pub fn pick_i32 ( x : i32 ) -> i32 {
61+ let x: Value < i32 > = Rc :: new ( RefCell :: new ( x) ) ;
62+ return ( ( * x. borrow ( ) ) + 1 ) ;
63+ }
64+ pub fn pick_i64 ( x : i64 ) -> i32 {
65+ let x: Value < i64 > = Rc :: new ( RefCell :: new ( x) ) ;
66+ return ( ( ( * x. borrow ( ) ) as i32 ) + 2 ) ;
67+ }
68+ pub fn solo ( x : i32 ) -> i32 {
69+ let x: Value < i32 > = Rc :: new ( RefCell :: new ( x) ) ;
70+ return ( ( * x. borrow ( ) ) + 3 ) ;
71+ }
72+ }
5773pub fn main ( ) {
5874 __cpp2rust_init_globals ( ) ;
5975 std:: process:: exit ( main_0 ( ) ) ;
6076}
6177fn main_0 ( ) -> i32 {
78+ let p1: Value < FnPtr < fn ( i32 ) -> i32 > > =
79+ Rc :: new ( RefCell :: new ( ( FnPtr :: < fn ( i32 ) -> i32 > :: new ( S :: pick_i32) ) ) ) ;
80+ let p2: Value < FnPtr < fn ( i32 ) -> i32 > > =
81+ Rc :: new ( RefCell :: new ( FnPtr :: < fn ( i32 ) -> i32 > :: new ( S :: solo) ) ) ;
82+ assert ! ( ( ( { ( * ( * p1. borrow( ) ) ) ( 5 , ) } ) == 6 ) ) ;
83+ assert ! ( ( ( { ( * ( * p2. borrow( ) ) ) ( 5 , ) } ) == 8 ) ) ;
84+ assert ! ( ( ( { S :: pick_i64( 5_i64 , ) } ) == 7 ) ) ;
85+ let h3: Value < Handler > = Rc :: new ( RefCell :: new ( Handler {
86+ tag : Rc :: new ( RefCell :: new ( 3 ) ) ,
87+ cb : Rc :: new ( RefCell :: new ( ( FnPtr :: < fn ( i32 ) -> i32 > :: new ( S :: pick_i32) ) ) ) ,
88+ } ) ) ;
89+ assert ! ( ( ( { ( * ( * ( * h3. borrow( ) ) . cb. borrow( ) ) ) ( 1 , ) } ) == 2 ) ) ;
6290 let h1: Value < Handler > = Rc :: new ( RefCell :: new ( Handler {
6391 tag : Rc :: new ( RefCell :: new ( 1 ) ) ,
6492 cb : Rc :: new ( RefCell :: new ( FnPtr :: < fn ( i32 ) -> i32 > :: new ( double_it_0) ) ) ,
0 commit comments