We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Alignment
Layout
1 parent 68d2e8a commit ddcdc0eCopy full SHA for ddcdc0e
library/core/src/ptr/alignment.rs
@@ -94,7 +94,12 @@ impl Alignment {
94
#[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")]
95
#[inline]
96
pub const fn as_usize(self) -> usize {
97
- self.0 as usize
+ // It would be possible to do this with `self.0 as _`, but that results
98
+ // in way more MIR -- mostly because of the assume -- which ends up
99
+ // impacting compilation time for things using `Layout`.
100
+
101
+ // SAFETY: this type is a subset of the possible values of usize.
102
+ unsafe { mem::transmute::<Alignment, usize>(self) }
103
}
104
105
/// Returns the alignment as a <code>[NonZero]<[usize]></code>.
0 commit comments