File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -203,3 +203,31 @@ fn cmp_default() {
203203 assert ! ( Fool ( false ) != Fool ( false ) ) ;
204204 assert_eq ! ( Fool ( false ) , Fool ( true ) ) ;
205205}
206+
207+ struct S ( i32 ) ;
208+
209+ impl const PartialEq for S {
210+ fn eq ( & self , other : & Self ) -> bool {
211+ self . 0 == other. 0
212+ }
213+ }
214+
215+ impl const PartialOrd for S {
216+ fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
217+ let ret = match ( self . 0 , other. 0 ) {
218+ ( a, b) if a > b => Ordering :: Greater ,
219+ ( a, b) if a < b => Ordering :: Less ,
220+ _ => Ordering :: Equal ,
221+ } ;
222+
223+ Some ( ret)
224+ }
225+ }
226+
227+ const _: ( ) = assert ! ( S ( 1 ) == S ( 1 ) ) ;
228+ const _: ( ) = assert ! ( S ( 0 ) != S ( 1 ) ) ;
229+
230+ const _: ( ) = assert ! ( S ( 1 ) <= S ( 1 ) ) ;
231+ const _: ( ) = assert ! ( S ( 1 ) >= S ( 1 ) ) ;
232+ const _: ( ) = assert ! ( S ( 0 ) < S ( 1 ) ) ;
233+ const _: ( ) = assert ! ( S ( 1 ) > S ( 0 ) ) ;
You can’t perform that action at this time.
0 commit comments