@@ -12,7 +12,7 @@ thread_local!(
1212thread_local ! (
1313 pub static moves_1: Value <i32 > = Rc :: new( RefCell :: new( 0 ) ) ;
1414) ;
15- #[ derive( Record , ByteRepr , VaArg , FnPtrArg , Default ) ]
15+ #[ derive( Record , ByteRepr , VaArg , FnPtrArg , MoveCtor , Default ) ]
1616#[ byte_size( 8 ) ]
1717pub struct Movable {
1818 #[ offset( 0 ) ]
@@ -21,35 +21,26 @@ pub struct Movable {
2121 pub y : i32 ,
2222}
2323impl Movable {
24- pub fn new ( x : i32 , y : i32 ) -> Self {
25- let x: Value < i32 > = Rc :: new ( RefCell :: new ( x) ) ;
26- let y: Value < i32 > = Rc :: new ( RefCell :: new ( y) ) ;
27- let __this: Value < Movable > = Rc :: new ( RefCell :: new ( Self {
28- x : ( * x. borrow ( ) ) ,
29- y : ( * y. borrow ( ) ) ,
30- } ) ) ;
31- let this: Ptr < Movable > = __this. as_pointer ( ) ;
32- Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
24+ pub fn new ( mut x : i32 , mut y : i32 ) -> Self {
25+ Self { x : x, y : y }
3326 }
3427 pub fn copy_from ( other : Ptr < Movable > ) -> Self {
35- let __this: Value < Movable > = Rc :: new ( RefCell :: new ( Self {
28+ let __this: Movable = Self {
3629 x : other. with ( |__s| __s. x ) ,
3730 y : other. with ( |__s| __s. y ) ,
38- } ) ) ;
39- let this: Ptr < Movable > = __this. as_pointer ( ) ;
31+ } ;
4032 ( * copies_0. with ( Value :: clone) . borrow_mut ( ) ) . prefix_inc ( ) ;
41- Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
33+ __this
4234 }
4335 pub fn move_from ( other : Ptr < Movable > ) -> Self {
44- let __this: Value < Movable > = Rc :: new ( RefCell :: new ( Self {
36+ let __this: Movable = Self {
4537 x : other. with ( |__s| __s. x ) ,
4638 y : other. with ( |__s| __s. y ) ,
47- } ) ) ;
48- let this: Ptr < Movable > = __this. as_pointer ( ) ;
39+ } ;
4940 field ! ( other, x) . write ( 0 ) ;
5041 field ! ( other, y) . write ( 0 ) ;
5142 ( * moves_1. with ( Value :: clone) . borrow_mut ( ) ) . prefix_inc ( ) ;
52- Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
43+ __this
5344 }
5445}
5546impl Clone for Movable {
@@ -77,37 +68,22 @@ pub fn main() {
7768}
7869fn main_0 ( ) -> i32 {
7970 let m: Value < Movable > = Rc :: new ( RefCell :: new ( Movable :: new ( { 3 } , { 4 } ) ) ) ;
80- let __decomp_2: Value < Movable > = Rc :: new ( RefCell :: new ( Movable :: move_from ( { m. as_pointer ( ) } ) ) ) ;
71+ let mut __decomp_2: Movable = Movable :: move_from ( { m. as_pointer ( ) } ) ;
8172 assert ! ( ( moves_1. with( |rc| * rc. borrow( ) ) == 1 ) ) ;
8273 assert ! ( ( copies_0. with( |rc| * rc. borrow( ) ) == 0 ) ) ;
83- assert ! ( ( { ( * __decomp_2. borrow ( ) ) . x } == 3 ) ) ;
84- assert ! ( ( { ( * __decomp_2. borrow ( ) ) . y } == 4 ) ) ;
74+ assert ! ( ( __decomp_2. x == 3 ) ) ;
75+ assert ! ( ( __decomp_2. y == 4 ) ) ;
8576 assert ! ( ( { ( * m. borrow( ) ) . x } == 0 ) ) ;
8677 assert ! ( ( { ( * m. borrow( ) ) . y } == 0 ) ) ;
8778 let h: Value < Holder > = Rc :: new ( RefCell :: new ( Holder {
8879 xs : Rc :: new ( RefCell :: new ( vec ! [ 1 , 2 , 3 ] ) ) ,
8980 ys : Rc :: new ( RefCell :: new ( vec ! [ 4 , 5 ] ) ) ,
9081 } ) ) ;
91- let __decomp_3: Value < Holder > =
92- Rc :: new ( RefCell :: new ( ( { HolderImpl :: extract ( & h. as_pointer ( ) ) } ) ) ) ;
93- assert ! ( ( ( * { ( * __decomp_3. borrow( ) ) . xs. clone( ) } . borrow( ) ) . len( ) == 3_usize ) ) ;
94- assert ! ( ( ( * { ( * __decomp_3. borrow( ) ) . ys. clone( ) } . borrow( ) ) . len( ) == 2_usize ) ) ;
95- assert ! (
96- ( ( elem!(
97- ( { ( * __decomp_3. borrow( ) ) . xs. as_pointer( ) } as Ptr <i32 >) ,
98- 2_usize
99- )
100- . read( ) )
101- == 3 )
102- ) ;
103- assert ! (
104- ( ( elem!(
105- ( { ( * __decomp_3. borrow( ) ) . ys. as_pointer( ) } as Ptr <i32 >) ,
106- 0_usize
107- )
108- . read( ) )
109- == 4 )
110- ) ;
82+ let mut __decomp_3: Holder = ( { HolderImpl :: extract ( & h. as_pointer ( ) ) } ) ;
83+ assert ! ( ( ( * __decomp_3. xs. borrow( ) ) . len( ) == 3_usize ) ) ;
84+ assert ! ( ( ( * __decomp_3. ys. borrow( ) ) . len( ) == 2_usize ) ) ;
85+ assert ! ( ( ( elem!( ( __decomp_3. xs. as_pointer( ) as Ptr <i32 >) , 2_usize ) . read( ) ) == 3 ) ) ;
86+ assert ! ( ( ( elem!( ( __decomp_3. ys. as_pointer( ) as Ptr <i32 >) , 0_usize ) . read( ) ) == 4 ) ) ;
11187 assert ! ( ( * { ( * h. borrow( ) ) . xs. clone( ) } . borrow( ) ) . is_empty( ) ) ;
11288 assert ! ( ( * { ( * h. borrow( ) ) . ys. clone( ) } . borrow( ) ) . is_empty( ) ) ;
11389 return 0 ;
0 commit comments