-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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.
676ff1f
to
bd960c9
Compare
r? libs-api |
This comment has been minimized.
This comment has been minimized.
…r=<try> Add some conversion trait impls
library/core/src/ascii/ascii_char.rs
Outdated
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 |
That 1 regression seems spurious. |
☔ The latest upstream changes (presumably #146494) made this pull request unmergeable. Please resolve the merge conflicts. |
- `impl AsRef<str> for AsciiChar` (unstable) - `impl AsMut<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]>`
8804742
to
5785a90
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
We talked about these in today's @rust-lang/libs-api meeting. The ones that stuck out to us were the Could you elaborate on these, and point to where they might have been discussed? Was there a discussion of those specifically, or are you just proposing them because |
cc @the8472 for potential additional questions/comments. |
Yes.
Unfortunately, |
Following up for clarity: other than If we can't consistently add trait impls for |
Done. |
@rfcbot merge |
Team member @the8472 has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
@the8472 should fcp be restarted without the T-libs label? |
@rfcbot cancel |
@the8472 proposal cancelled. |
@rfcbot merge |
Team member @the8472 has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
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.