@@ -7,65 +7,54 @@ use std::io::{Read, Seek, Write};
77use std:: os:: fd:: AsFd ;
88use std:: rc:: { Rc , Weak } ;
99#[ derive( ) ]
10- pub struct WOFF2Params {
11- pub extended_metadata : Value < Vec < u8 > > ,
12- pub brotli_quality : Value < i32 > ,
13- pub allow_transforms : Value < bool > ,
10+ pub struct S {
11+ pub a : Value < i32 > ,
12+ pub b : Value < bool > ,
1413}
15- impl WOFF2Params {
16- pub fn WOFF2Params ( ) -> Self {
14+ impl S {
15+ pub fn S ( ) -> Self {
1716 let mut this = Self {
18- extended_metadata : Rc :: new ( RefCell :: new (
19- Ptr :: from_string_literal ( b"" )
20- . to_c_string_iterator ( )
21- . chain ( std:: iter:: once ( 0 ) )
22- . collect :: < Vec < u8 > > ( ) ,
23- ) ) ,
24- brotli_quality : Rc :: new ( RefCell :: new ( 11 ) ) ,
25- allow_transforms : Rc :: new ( RefCell :: new ( true ) ) ,
17+ a : Rc :: new ( RefCell :: new ( 11 ) ) ,
18+ b : Rc :: new ( RefCell :: new ( true ) ) ,
2619 } ;
2720 this
2821 }
2922}
30- impl Clone for WOFF2Params {
23+ impl Clone for S {
3124 fn clone ( & self ) -> Self {
3225 let mut this = Self {
33- extended_metadata : Rc :: new ( RefCell :: new ( ( * self . extended_metadata . borrow ( ) ) . clone ( ) ) ) ,
34- brotli_quality : Rc :: new ( RefCell :: new ( ( * self . brotli_quality . borrow ( ) ) ) ) ,
35- allow_transforms : Rc :: new ( RefCell :: new ( ( * self . allow_transforms . borrow ( ) ) ) ) ,
26+ a : Rc :: new ( RefCell :: new ( ( * self . a . borrow ( ) ) ) ) ,
27+ b : Rc :: new ( RefCell :: new ( ( * self . b . borrow ( ) ) ) ) ,
3628 } ;
3729 this
3830 }
3931}
40- impl Default for WOFF2Params {
32+ impl Default for S {
4133 fn default ( ) -> Self {
42- { WOFF2Params :: WOFF2Params ( ) }
34+ { S :: S ( ) }
4335 }
4436}
45- impl ByteRepr for WOFF2Params {
37+ impl ByteRepr for S {
4638 fn byte_size ( ) -> usize {
47- 40
39+ 8
4840 }
4941 fn to_bytes ( & self , buf : & mut [ u8 ] ) {
50- ( * self . extended_metadata . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..32 ] ) ;
51- ( * self . brotli_quality . borrow ( ) ) . to_bytes ( & mut buf[ 32 ..36 ] ) ;
52- ( * self . allow_transforms . borrow ( ) ) . to_bytes ( & mut buf[ 36 ..37 ] ) ;
42+ ( * self . a . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
43+ ( * self . b . borrow ( ) ) . to_bytes ( & mut buf[ 4 ..5 ] ) ;
5344 }
5445 fn from_bytes ( buf : & [ u8 ] ) -> Self {
5546 Self {
56- extended_metadata : Rc :: new ( RefCell :: new ( <Vec < u8 > >:: from_bytes ( & buf[ 0 ..32 ] ) ) ) ,
57- brotli_quality : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 32 ..36 ] ) ) ) ,
58- allow_transforms : Rc :: new ( RefCell :: new ( <bool >:: from_bytes ( & buf[ 36 ..37 ] ) ) ) ,
47+ a : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
48+ b : Rc :: new ( RefCell :: new ( <bool >:: from_bytes ( & buf[ 4 ..5 ] ) ) ) ,
5949 }
6050 }
6151}
6252pub fn main ( ) {
6353 std:: process:: exit ( main_0 ( ) ) ;
6454}
6555fn main_0 ( ) -> i32 {
66- let params: Value < WOFF2Params > = Rc :: new ( RefCell :: new ( WOFF2Params :: WOFF2Params ( ) ) ) ;
67- assert ! ( ( ( ( * ( * params. borrow( ) ) . extended_metadata. borrow( ) ) . len( ) - 1 ) == 0_usize ) ) ;
68- assert ! ( ( ( * ( * params. borrow( ) ) . brotli_quality. borrow( ) ) == 11 ) ) ;
69- assert ! ( ( ( ( * ( * params. borrow( ) ) . allow_transforms. borrow( ) ) as i32 ) == ( true as i32 ) ) ) ;
56+ let s: Value < S > = Rc :: new ( RefCell :: new ( S :: S ( ) ) ) ;
57+ assert ! ( ( ( * ( * s. borrow( ) ) . a. borrow( ) ) == 11 ) ) ;
58+ assert ! ( ( ( ( * ( * s. borrow( ) ) . b. borrow( ) ) as i32 ) == ( true as i32 ) ) ) ;
7059 return 0 ;
7160}
0 commit comments