@@ -117,11 +117,120 @@ pub fn operator_lt_7(a: i32, b: Ptr<S>) -> bool {
117117 _lhs < ( * ( * b. upgrade ( ) . deref ( ) ) . v . borrow ( ) )
118118 } ;
119119}
120+ #[ derive( Default ) ]
121+ pub struct V {
122+ pub v : Value < i32 > ,
123+ }
124+ impl std:: cmp:: Ord for V {
125+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
126+ {
127+ if operator_lt_8 ( self . clone ( ) , other. clone ( ) ) {
128+ std:: cmp:: Ordering :: Less
129+ } else if operator_lt_8 ( other. clone ( ) , self . clone ( ) ) {
130+ std:: cmp:: Ordering :: Greater
131+ } else {
132+ std:: cmp:: Ordering :: Equal
133+ }
134+ }
135+ }
136+ }
137+ impl std:: cmp:: PartialOrd for V {
138+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
139+ Some ( self . cmp ( other) )
140+ }
141+ }
142+ impl std:: cmp:: PartialEq for V {
143+ fn eq ( & self , other : & Self ) -> bool {
144+ { operator_eq_9 ( self . clone ( ) , other. clone ( ) ) }
145+ }
146+ }
147+ impl std:: cmp:: Eq for V { }
148+ impl Clone for V {
149+ fn clone ( & self ) -> Self {
150+ let __this: Value < V > = Rc :: new ( RefCell :: new ( Self {
151+ v : Rc :: new ( RefCell :: new ( ( * self . v . borrow ( ) ) ) ) ,
152+ } ) ) ;
153+ let this: Ptr < V > = __this. as_pointer ( ) ;
154+ Rc :: try_unwrap ( __this) . ok ( ) . unwrap ( ) . into_inner ( )
155+ }
156+ }
157+ impl ByteRepr for V {
158+ fn byte_size ( ) -> usize {
159+ 4
160+ }
161+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
162+ ( * self . v . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
163+ }
164+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
165+ Self {
166+ v : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
167+ }
168+ }
169+ }
170+ pub fn operator_eq_9 ( a : V , b : V ) -> bool {
171+ let a: Value < V > = Rc :: new ( RefCell :: new ( a) ) ;
172+ let b: Value < V > = Rc :: new ( RefCell :: new ( b) ) ;
173+ return ( ( * ( * a. borrow ( ) ) . v . borrow ( ) ) == ( * ( * b. borrow ( ) ) . v . borrow ( ) ) ) ;
174+ }
175+ pub fn operator_ne_10 ( a : V , b : V ) -> bool {
176+ let a: Value < V > = Rc :: new ( RefCell :: new ( a) ) ;
177+ let b: Value < V > = Rc :: new ( RefCell :: new ( b) ) ;
178+ return ( ( * ( * a. borrow ( ) ) . v . borrow ( ) ) != ( * ( * b. borrow ( ) ) . v . borrow ( ) ) ) ;
179+ }
180+ pub fn operator_lt_8 ( a : V , b : V ) -> bool {
181+ let a: Value < V > = Rc :: new ( RefCell :: new ( a) ) ;
182+ let b: Value < V > = Rc :: new ( RefCell :: new ( b) ) ;
183+ return ( ( * ( * a. borrow ( ) ) . v . borrow ( ) ) < ( * ( * b. borrow ( ) ) . v . borrow ( ) ) ) ;
184+ }
185+ pub fn operator_gt_11 ( a : V , b : V ) -> bool {
186+ let a: Value < V > = Rc :: new ( RefCell :: new ( a) ) ;
187+ let b: Value < V > = Rc :: new ( RefCell :: new ( b) ) ;
188+ return ( ( * ( * a. borrow ( ) ) . v . borrow ( ) ) > ( * ( * b. borrow ( ) ) . v . borrow ( ) ) ) ;
189+ }
120190pub fn main ( ) {
121191 __cpp2rust_init_globals ( ) ;
122192 std:: process:: exit ( main_0 ( ) ) ;
123193}
124194fn main_0 ( ) -> i32 {
195+ let x: Value < V > = Rc :: new ( RefCell :: new ( V {
196+ v : Rc :: new ( RefCell :: new ( 1 ) ) ,
197+ } ) ) ;
198+ let y: Value < V > = Rc :: new ( RefCell :: new ( V {
199+ v : Rc :: new ( RefCell :: new ( 2 ) ) ,
200+ } ) ) ;
201+ let z: Value < V > = Rc :: new ( RefCell :: new ( V {
202+ v : Rc :: new ( RefCell :: new ( 1 ) ) ,
203+ } ) ) ;
204+ assert ! (
205+ ( {
206+ let _a: V = ( * x. borrow( ) ) . clone( ) ;
207+ operator_eq_9( _a, ( * z. borrow( ) ) . clone( ) )
208+ } )
209+ ) ;
210+ assert ! (
211+ ( {
212+ let _a: V = ( * x. borrow( ) ) . clone( ) ;
213+ operator_ne_10( _a, ( * y. borrow( ) ) . clone( ) )
214+ } )
215+ ) ;
216+ assert ! (
217+ ( {
218+ let _a: V = ( * x. borrow( ) ) . clone( ) ;
219+ operator_lt_8( _a, ( * y. borrow( ) ) . clone( ) )
220+ } )
221+ ) ;
222+ assert ! (
223+ ( {
224+ let _a: V = ( * y. borrow( ) ) . clone( ) ;
225+ operator_gt_11( _a, ( * x. borrow( ) ) . clone( ) )
226+ } )
227+ ) ;
228+ assert ! (
229+ !( {
230+ let _a: V = ( * y. borrow( ) ) . clone( ) ;
231+ operator_lt_8( _a, ( * x. borrow( ) ) . clone( ) )
232+ } )
233+ ) ;
125234 let a: Value < S > = Rc :: new ( RefCell :: new ( S {
126235 v : Rc :: new ( RefCell :: new ( 1 ) ) ,
127236 } ) ) ;
0 commit comments