Skip to content

Rename <*{mut,const} T>::as_{const,mut} to cast_ #98174

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

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/core/src/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<T: ?Sized> *const T {
/// refactored.
#[unstable(feature = "ptr_const_cast", issue = "92675")]
#[rustc_const_unstable(feature = "ptr_const_cast", issue = "92675")]
pub const fn as_mut(self) -> *mut T {
pub const fn cast_mut(self) -> *mut T {
self as _
}

Expand Down
8 changes: 5 additions & 3 deletions library/core/src/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ impl<T: ?Sized> *mut T {
/// refactored.
///
/// While not strictly required (`*mut T` coerces to `*const T`), this is provided for symmetry
/// with `as_mut()` on `*const T` and may have documentation value if used instead of implicit
/// with [`cast_mut`] on `*const T` and may have documentation value if used instead of implicit
/// coercion.
///
/// [`cast_mut`]: #method.cast_mut
#[unstable(feature = "ptr_const_cast", issue = "92675")]
#[rustc_const_unstable(feature = "ptr_const_cast", issue = "92675")]
pub const fn as_const(self) -> *const T {
pub const fn cast_const(self) -> *const T {
self as _
}

Expand Down Expand Up @@ -289,7 +291,7 @@ impl<T: ?Sized> *mut T {
/// For the mutable counterpart see [`as_mut`].
///
/// [`as_uninit_ref`]: #method.as_uninit_ref-1
/// [`as_mut`]: #method.as_mut-1
/// [`as_mut`]: #method.as_mut
///
/// # Safety
///
Expand Down