File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,40 +6,20 @@ use std::io::prelude::*;
66use std:: io:: { Read , Seek , Write } ;
77use std:: os:: fd:: AsFd ;
88use std:: rc:: { Rc , Weak } ;
9+ #[ derive( Default ) ]
910pub struct basic {
10- __buf : Rc < RefCell < Vec < u8 > > > ,
1111 pub i : Value < i32 > ,
1212 pub f : Value < f32 > ,
1313}
14- impl Default for basic {
15- fn default ( ) -> Self {
16- let __buf = Rc :: new ( RefCell :: new ( vec ! [ 0u8 ; 4 ] ) ) ;
17- Self {
18- __buf : __buf. clone ( ) ,
19- i : Value :: new_reinterpreted (
20- Rc :: new ( SliceOriginalAlloc {
21- weak : Rc :: downgrade ( & __buf) ,
22- } ) ,
23- 0 ,
24- ) ,
25- f : Value :: new_reinterpreted (
26- Rc :: new ( SliceOriginalAlloc {
27- weak : Rc :: downgrade ( & __buf) ,
28- } ) ,
29- 0 ,
30- ) ,
31- }
32- }
33- }
3414impl ByteRepr for basic { }
3515pub fn main ( ) {
3616 std:: process:: exit ( main_0 ( ) ) ;
3717}
3818fn main_0 ( ) -> i32 {
3919 let u: Value < basic > = <Value < basic > >:: default ( ) ;
40- ( * u. borrow ( ) ) . i . write ( 42 ) ;
41- assert ! ( ( ( * u. borrow( ) ) . i. read ( ) == 42 ) ) ;
42- ( * u. borrow ( ) ) . f . write ( 3.140000105E+0 ) ;
43- assert ! ( ( ( * u. borrow( ) ) . f. read ( ) == 3.140000105E+0 ) ) ;
20+ ( * ( * u. borrow ( ) ) . i . borrow_mut ( ) ) = 42 ;
21+ assert ! ( ( ( * ( * u. borrow( ) ) . i. borrow ( ) ) == 42 ) ) ;
22+ ( * ( * u. borrow ( ) ) . f . borrow_mut ( ) ) = 3.140000105E+0 ;
23+ assert ! ( ( ( * ( * u. borrow( ) ) . f. borrow ( ) ) == 3.140000105E+0 ) ) ;
4424 return 0 ;
4525}
Original file line number Diff line number Diff line change @@ -6,15 +6,11 @@ use std::collections::BTreeMap;
66use std:: io:: { Read , Seek , Write } ;
77use std:: os:: fd:: { AsFd , FromRawFd , IntoRawFd } ;
88use std:: rc:: Rc ;
9- pub union basic {
9+ #[ derive( Copy , Clone , Default ) ]
10+ pub struct basic {
1011 pub i : i32 ,
1112 pub f : f32 ,
1213}
13- impl Default for basic {
14- fn default ( ) -> Self {
15- unsafe { :: std:: mem:: MaybeUninit :: zeroed ( ) . assume_init ( ) }
16- }
17- }
1814pub fn main ( ) {
1915 unsafe {
2016 std:: process:: exit ( main_0 ( ) as i32 ) ;
You can’t perform that action at this time.
0 commit comments