File tree Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change 1919
2020use self :: Ordering :: * ;
2121
22- use mem;
2322use marker:: Sized ;
2423use option:: Option :: { self , Some } ;
2524
@@ -119,10 +118,6 @@ pub enum Ordering {
119118}
120119
121120impl Ordering {
122- unsafe fn from_i8_unchecked ( v : i8 ) -> Ordering {
123- mem:: transmute ( v)
124- }
125-
126121 /// Reverse the `Ordering`.
127122 ///
128123 /// * `Less` becomes `Greater`.
@@ -155,14 +150,10 @@ impl Ordering {
155150 #[ inline]
156151 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
157152 pub fn reverse ( self ) -> Ordering {
158- unsafe {
159- // this compiles really nicely (to a single instruction);
160- // an explicit match has a pile of branches and
161- // comparisons.
162- //
163- // NB. it is safe because of the explicit discriminants
164- // given above.
165- Ordering :: from_i8_unchecked ( -( self as i8 ) )
153+ match self {
154+ Less => Greater ,
155+ Equal => Equal ,
156+ Greater => Less ,
166157 }
167158 }
168159}
You can’t perform that action at this time.
0 commit comments