Skip to content

Commit 4d5b4a8

Browse files
authored
Rollup merge of #102862 - scottmcm:more-alignment-traits, r=thomcc
From<Alignment> for usize & NonZeroUsize Since you mentioned these two in #102072 (comment), r? `@thomcc` Tracking Issue: #102070
2 parents efbef07 + 0718aec commit 4d5b4a8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Diff for: library/core/src/ptr/alignment.rs

+16
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]

Diff for: src/test/ui/try-trait/bad-interconversion.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | Ok(Err(123_i32)?)
1616
<f64 as From<i16>>
1717
<f64 as From<i32>>
1818
<f64 as From<i8>>
19-
and 67 others
19+
and 68 others
2020
= note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>`
2121

2222
error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`

0 commit comments

Comments
 (0)