From<Alignment> for usize & NonZeroUsize

This commit is contained in:
Scott McMurray 2022-10-09 15:12:43 -07:00
parent 81f3919303
commit 0718aeceb3
2 changed files with 17 additions and 1 deletions

View File

@ -146,6 +146,22 @@ impl TryFrom<usize> for Alignment {
}
}
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
impl From<Alignment> for NonZeroUsize {
#[inline]
fn from(align: Alignment) -> NonZeroUsize {
align.as_nonzero()
}
}
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
impl From<Alignment> for usize {
#[inline]
fn from(align: Alignment) -> usize {
align.as_usize()
}
}
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
impl cmp::Ord for Alignment {
#[inline]

View File

@ -16,7 +16,7 @@ LL | Ok(Err(123_i32)?)
<f64 as From<i16>>
<f64 as From<i32>>
<f64 as From<i8>>
and 67 others
and 68 others
= note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>`
error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`