@@ -48,13 +48,15 @@ pub struct S {
4848 pub a : Value < i32 > ,
4949 pub b : Value < u8 > ,
5050 pub c : Value < Inner > ,
51+ pub d : Value < Inner > ,
5152}
5253impl Clone for S {
5354 fn clone ( & self ) -> Self {
5455 let mut this = Self {
5556 a : Rc :: new ( RefCell :: new ( ( * self . a . borrow ( ) ) ) ) ,
5657 b : Rc :: new ( RefCell :: new ( ( * self . b . borrow ( ) ) ) ) ,
5758 c : Rc :: new ( RefCell :: new ( ( * self . c . borrow ( ) ) . clone ( ) ) ) ,
59+ d : Rc :: new ( RefCell :: new ( ( * self . d . borrow ( ) ) . clone ( ) ) ) ,
5860 } ;
5961 this
6062 }
@@ -68,41 +70,39 @@ impl Default for S {
6870 x : Rc :: new ( RefCell :: new ( 3 ) ) ,
6971 y : Rc :: new ( RefCell :: new ( 4 ) ) ,
7072 } ) ) ,
73+ d : <Value < Inner > >:: default ( ) ,
7174 }
7275 }
7376}
7477impl ByteRepr for S {
7578 fn byte_size ( ) -> usize {
76- 16
79+ 24
7780 }
7881 fn to_bytes ( & self , buf : & mut [ u8 ] ) {
7982 ( * self . a . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
8083 ( * self . b . borrow ( ) ) . to_bytes ( & mut buf[ 4 ..5 ] ) ;
8184 ( * self . c . borrow ( ) ) . to_bytes ( & mut buf[ 8 ..16 ] ) ;
85+ ( * self . d . borrow ( ) ) . to_bytes ( & mut buf[ 16 ..24 ] ) ;
8286 }
8387 fn from_bytes ( buf : & [ u8 ] ) -> Self {
8488 Self {
8589 a : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
8690 b : Rc :: new ( RefCell :: new ( <u8 >:: from_bytes ( & buf[ 4 ..5 ] ) ) ) ,
8791 c : Rc :: new ( RefCell :: new ( <Inner >:: from_bytes ( & buf[ 8 ..16 ] ) ) ) ,
92+ d : Rc :: new ( RefCell :: new ( <Inner >:: from_bytes ( & buf[ 16 ..24 ] ) ) ) ,
8893 }
8994 }
9095}
9196pub fn main ( ) {
9297 std:: process:: exit ( main_0 ( ) ) ;
9398}
9499fn main_0 ( ) -> i32 {
95- let s: Value < S > = Rc :: new ( RefCell :: new ( S {
96- a : Rc :: new ( RefCell :: new ( 1 ) ) ,
97- b : Rc :: new ( RefCell :: new ( 2_u8 ) ) ,
98- c : Rc :: new ( RefCell :: new ( Inner {
99- x : Rc :: new ( RefCell :: new ( 3 ) ) ,
100- y : Rc :: new ( RefCell :: new ( 4 ) ) ,
101- } ) ) ,
102- } ) ) ;
100+ let s: Value < S > = Rc :: new ( RefCell :: new ( <S >:: default ( ) ) ) ;
103101 assert ! ( ( ( * ( * s. borrow( ) ) . a. borrow( ) ) == 1 ) ) ;
104102 assert ! ( ( ( ( * ( * s. borrow( ) ) . b. borrow( ) ) as i32 ) == 2 ) ) ;
105103 assert ! ( ( ( * ( * ( * s. borrow( ) ) . c. borrow( ) ) . x. borrow( ) ) == 3 ) ) ;
106104 assert ! ( ( ( * ( * ( * s. borrow( ) ) . c. borrow( ) ) . y. borrow( ) ) == 4 ) ) ;
105+ assert ! ( ( ( * ( * ( * s. borrow( ) ) . d. borrow( ) ) . x. borrow( ) ) == 3 ) ) ;
106+ assert ! ( ( ( * ( * ( * s. borrow( ) ) . d. borrow( ) ) . y. borrow( ) ) == 4 ) ) ;
107107 return 0 ;
108108}
0 commit comments