Skip to content

Commit 41e51f6

Browse files
authored
Rollup merge of #102862 - scottmcm:more-alignment-traits, r=thomcc
From<Alignment> for usize & NonZeroUsize Since you mentioned these two in rust-lang/rust#102072 (comment), r? ``@thomcc`` Tracking Issue: rust-lang/rust#102070
2 parents e6280cd + d7c692a commit 41e51f6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

core/src/ptr/alignment.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,22 @@ impl TryFrom<usize> for Alignment {
146146
}
147147
}
148148

149+
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
150+
impl From<Alignment> for NonZeroUsize {
151+
#[inline]
152+
fn from(align: Alignment) -> NonZeroUsize {
153+
align.as_nonzero()
154+
}
155+
}
156+
157+
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
158+
impl From<Alignment> for usize {
159+
#[inline]
160+
fn from(align: Alignment) -> usize {
161+
align.as_usize()
162+
}
163+
}
164+
149165
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
150166
impl cmp::Ord for Alignment {
151167
#[inline]

0 commit comments

Comments
 (0)