@@ -182,6 +182,40 @@ pub fn operator_eq_7(mut a: Boolish, mut b: Boolish) -> MyBool {
182182pub fn operator_lt_6 ( mut a : Boolish , mut b : Boolish ) -> MyBool {
183183 return MyBool :: new ( { ( a. v < b. v ) } ) ;
184184}
185+ #[ derive( Record , ByteRepr , FnPtrArg , Default ) ]
186+ #[ byte_size( 1 ) ]
187+ pub struct RefBool {
188+ #[ offset( 0 ) ]
189+ pub value : bool ,
190+ }
191+ impl RefBool {
192+ pub fn new ( mut v : bool ) -> Self {
193+ Self { value : v }
194+ }
195+ }
196+ thread_local ! (
197+ pub static ref_true_8: Value <RefBool > = Rc :: new( RefCell :: new( RefBool :: new( { true } ) ) ) ;
198+ ) ;
199+ #[ derive( Clone , Record , ByteRepr , VaArg , FnPtrArg , Default ) ]
200+ #[ byte_size( 4 ) ]
201+ pub struct RefInt {
202+ #[ offset( 0 ) ]
203+ pub v : i32 ,
204+ }
205+ impl std:: cmp:: PartialEq for RefInt {
206+ fn eq ( & self , other : & Self ) -> bool {
207+ {
208+ {
209+ let __cmp = RefIntImpl :: operator_eq (
210+ & Rc :: new ( RefCell :: new ( RefInt { v : self . v . clone ( ) } ) ) . as_pointer ( ) ,
211+ Rc :: new ( RefCell :: new ( RefInt { v : other. v . clone ( ) } ) ) . as_pointer ( ) ,
212+ ) ;
213+ RefBoolImpl :: to_bool ( & __cmp)
214+ }
215+ }
216+ }
217+ }
218+ impl std:: cmp:: Eq for RefInt { }
185219pub fn main ( ) {
186220 __cpp2rust_init_globals ( ) ;
187221 std:: process:: exit ( main_0 ( ) ) ;
@@ -317,6 +351,33 @@ fn main_0() -> i32 {
317351 ( ( { ( * bs. borrow( ) ) [ ( 0 ) as usize ] . v } == 1 ) && ( { ( * bs. borrow( ) ) [ ( 1 ) as usize ] . v } == 2 ) )
318352 && ( { ( * bs. borrow( ) ) [ ( 2 ) as usize ] . v } == 3 )
319353 ) ;
354+ let ri1: Value < RefInt > = Rc :: new ( RefCell :: new ( RefInt { v : 1 } ) ) ;
355+ let ri2: Value < RefInt > = Rc :: new ( RefCell :: new ( RefInt { v : 2 } ) ) ;
356+ assert ! (
357+ ( {
358+ RefBoolImpl :: to_bool(
359+ & ( { RefIntImpl :: operator_eq( & ri1. as_pointer( ) , ri2. as_pointer( ) ) } ) ,
360+ )
361+ } )
362+ ) ;
363+ let ris: Value < Box < [ RefInt ] > > =
364+ Rc :: new ( RefCell :: new ( Box :: new ( [ RefInt { v : 1 } , RefInt { v : 2 } ] ) ) ) ;
365+ assert ! (
366+ ( {
367+ let count = ( ( ris. as_pointer( ) as Ptr <RefInt >)
368+ . offset( ( 2 ) as isize )
369+ . get_offset( )
370+ - ( ris. as_pointer( ) as Ptr <RefInt >) . get_offset( ) ) as usize ;
371+ ( ris. as_pointer( ) as Ptr <RefInt >) . offset(
372+ ( ris. as_pointer( ) as Ptr <RefInt >)
373+ . clone( )
374+ . into_iter( )
375+ . take( count)
376+ . position( |value_0| value_0. read( ) == ( * ri2. borrow( ) ) )
377+ . unwrap_or( count) as isize ,
378+ )
379+ } == ( ris. as_pointer( ) as Ptr <RefInt >) )
380+ ) ;
320381 return 0 ;
321382}
322383pub trait CustomImpl {
@@ -363,4 +424,22 @@ impl MyBoolImpl for Ptr<MyBool> {
363424 return ( * self ) . with ( |__s| __s. value ) ;
364425 }
365426}
366- pub fn __cpp2rust_init_globals ( ) { }
427+ pub trait RefBoolImpl {
428+ fn to_bool ( & self ) -> bool ;
429+ }
430+ impl RefBoolImpl for Ptr < RefBool > {
431+ fn to_bool ( & self ) -> bool {
432+ return ( * self ) . with ( |__s| __s. value ) ;
433+ }
434+ }
435+ pub trait RefIntImpl {
436+ fn operator_eq ( & self , _a0 : Ptr < RefInt > ) -> Ptr < RefBool > ;
437+ }
438+ impl RefIntImpl for Ptr < RefInt > {
439+ fn operator_eq ( & self , _a0 : Ptr < RefInt > ) -> Ptr < RefBool > {
440+ return ref_true_8. with ( |v| v. as_pointer ( ) ) ;
441+ }
442+ }
443+ pub fn __cpp2rust_init_globals ( ) {
444+ let _ = ref_true_8. with ( |_| ( ) ) ;
445+ }
0 commit comments