From d7c692ab56eab77a9d333d69d9dae7db989a855d Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sun, 9 Oct 2022 15:12:43 -0700 Subject: [PATCH] From for usize & NonZeroUsize --- core/src/ptr/alignment.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/src/ptr/alignment.rs b/core/src/ptr/alignment.rs index bdebf8baa..56c5e6cb7 100644 --- a/core/src/ptr/alignment.rs +++ b/core/src/ptr/alignment.rs @@ -146,6 +146,22 @@ impl TryFrom for Alignment { } } +#[unstable(feature = "ptr_alignment_type", issue = "102070")] +impl From for NonZeroUsize { + #[inline] + fn from(align: Alignment) -> NonZeroUsize { + align.as_nonzero() + } +} + +#[unstable(feature = "ptr_alignment_type", issue = "102070")] +impl From for usize { + #[inline] + fn from(align: Alignment) -> usize { + align.as_usize() + } +} + #[unstable(feature = "ptr_alignment_type", issue = "102070")] impl cmp::Ord for Alignment { #[inline]