File tree 1 file changed +4
-13
lines changed
1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change 19
19
20
20
use self :: Ordering :: * ;
21
21
22
- use mem;
23
22
use marker:: Sized ;
24
23
use option:: Option :: { self , Some } ;
25
24
@@ -119,10 +118,6 @@ pub enum Ordering {
119
118
}
120
119
121
120
impl Ordering {
122
- unsafe fn from_i8_unchecked ( v : i8 ) -> Ordering {
123
- mem:: transmute ( v)
124
- }
125
-
126
121
/// Reverse the `Ordering`.
127
122
///
128
123
/// * `Less` becomes `Greater`.
@@ -155,14 +150,10 @@ impl Ordering {
155
150
#[ inline]
156
151
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
157
152
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 ,
166
157
}
167
158
}
168
159
}
You can’t perform that action at this time.
0 commit comments