-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Add some conversion trait impls #145504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add some conversion trait impls #145504
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
This comment has been minimized.
This comment has been minimized.
7ef29d9
to
3a96604
Compare
This comment has been minimized.
This comment has been minimized.
3a96604
to
676ff1f
Compare
- `impl AsRef<str> for AsciiChar` (unstable) - `impl<T, const N: usize> From<[MaybeUninit<T>; N]> for MaybeUninit<[T; N]>` - `impl<T, const N: usize> AsRef<[MaybeUninit<T>; N]> for MaybeUninit<[T; N]>` - `impl<T, const N: usize> AsRef<[MaybeUninit<T>]> for MaybeUninit<[T; N]>` - `impl<T, const N: usize> AsMut<[MaybeUninit<T>; N]> for MaybeUninit<[T; N]>` - `impl<T, const N: usize> AsMut<[MaybeUninit<T>]> for MaybeUninit<[T; N]>` - `impl<T, const N: usize> From<MaybeUninit<[T; N]>> for [MaybeUninit<T>; N]` - `impl<T, const N: usize> AsRef<[Cell<T>; N]> for Cell<[T; N]>` - `impl<T, const N: usize> AsRef<[Cell<T>]> for Cell<[T; N]>` - `impl<T> AsRef<[Cell<T>]> for Cell<[T]>`
676ff1f
to
bd960c9
Compare
r? libs-api |
This comment has been minimized.
This comment has been minimized.
…r=<try> Add some conversion trait impls
impl AsMut<str> for AsciiChar { | ||
#[inline(always)] | ||
fn as_mut(&mut self) -> &mut str { | ||
let ascii_ptr: *mut [Self] = crate::slice::from_mut(self); | ||
let str_ptr = ascii_ptr as *mut str; | ||
// SAFETY: Each ASCII codepoint in UTF-8 is encoded as one single-byte | ||
// code unit having the same value as the ASCII byte. | ||
unsafe { &mut *str_ptr } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably be implemented in a new as_mut_str
method, similar to as_str
Also, could everything here use #[inline]
without the always?
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
impl AsRef<str> for AsciiChar
(unstable, cc Tracking Issue forascii::Char
(ACP 179) #110998)impl AsMut<str> for AsciiChar
(unstable, cc Tracking Issue forascii::Char
(ACP 179) #110998)impl<T, const N: usize> From<[MaybeUninit<T>; N]> for MaybeUninit<[T; N]>
(cc Tracking Issue for MaybeUninit methods for arrays #96097)impl<T, const N: usize> AsRef<[MaybeUninit<T>; N]> for MaybeUninit<[T; N]>
(cc Tracking Issue for MaybeUninit methods for arrays #96097)impl<T, const N: usize> AsRef<[MaybeUninit<T>]> for MaybeUninit<[T; N]>
(cc Tracking Issue for MaybeUninit methods for arrays #96097)impl<T, const N: usize> AsMut<[MaybeUninit<T>; N]> for MaybeUninit<[T; N]>
(cc Tracking Issue for MaybeUninit methods for arrays #96097)impl<T, const N: usize> AsMut<[MaybeUninit<T>]> for MaybeUninit<[T; N]>
(cc Tracking Issue for MaybeUninit methods for arrays #96097)impl<T, const N: usize> From<MaybeUninit<[T; N]>> for [MaybeUninit<T>; N]
(cc Tracking Issue for MaybeUninit methods for arrays #96097)impl<T, const N: usize> AsRef<[Cell<T>; N]> for Cell<[T; N]>
(equivalent ofas_array_of_cells
, cc Tracking Issue for Cell::as_array_of_cells #88248)impl<T, const N: usize> AsRef<[Cell<T>]> for Cell<[T; N]>
impl<T> AsRef<[Cell<T>]> for Cell<[T]>
(equivalent ofas_slice_of_cells
)@rustbot label T-libs-api needs-fcp -T-libs
I’ve tried to only add impls that are unlikely to cause single-applicable-impl inference breakage.