File tree Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -1287,7 +1287,7 @@ impl<T, const N: usize> MaybeUninit<[T; N]> {
12871287 #[ inline]
12881288 pub const fn transpose ( self ) -> [ MaybeUninit < T > ; N ] {
12891289 // SAFETY: T and MaybeUninit<T> have the same layout
1290- unsafe { super :: transmute_copy ( & ManuallyDrop :: new ( self ) ) }
1290+ unsafe { intrinsics :: transmute_unchecked ( self ) }
12911291 }
12921292}
12931293
@@ -1307,6 +1307,6 @@ impl<T, const N: usize> [MaybeUninit<T>; N] {
13071307 #[ inline]
13081308 pub const fn transpose ( self ) -> MaybeUninit < [ T ; N ] > {
13091309 // SAFETY: T and MaybeUninit<T> have the same layout
1310- unsafe { super :: transmute_copy ( & ManuallyDrop :: new ( self ) ) }
1310+ unsafe { intrinsics :: transmute_unchecked ( self ) }
13111311 }
13121312}
Original file line number Diff line number Diff line change 11// See src/libstd/primitive_docs.rs for documentation.
22
33use crate :: cmp:: Ordering :: { self , * } ;
4- use crate :: mem:: transmute;
54
65// Recursive macro for implementing n-ary tuple functions and operations
76//
@@ -142,16 +141,13 @@ macro_rules! maybe_tuple_doc {
142141#[ inline]
143142const fn ordering_is_some ( c : Option < Ordering > , x : Ordering ) -> bool {
144143 // FIXME: Just use `==` once that's const-stable on `Option`s.
145- // This isn't using `match` because that optimizes worse due to
146- // making a two-step check (`Some` *then* the inner value).
147-
148- // SAFETY: There's no public guarantee for `Option<Ordering>`,
149- // but we're core so we know that it's definitely a byte.
150- unsafe {
151- let c: i8 = transmute ( c) ;
152- let x: i8 = transmute ( Some ( x) ) ;
153- c == x
154- }
144+ // This is mapping `None` to 2 and then doing the comparison afterwards
145+ // because it optimizes better (`None::<Ordering>` is represented as 2).
146+ x as i8
147+ == match c {
148+ Some ( c) => c as i8 ,
149+ None => 2 ,
150+ }
155151}
156152
157153// Constructs an expression that performs a lexical ordering using method `$rel`.
You can’t perform that action at this time.
0 commit comments