Skip to content

Commit ad31d5c

Browse files
authored
Rollup merge of #98174 - Kixunil:rename_ptr_as_mut_const_to_cast, r=scottmcm
Rename `<*{mut,const} T>::as_{const,mut}` to `cast_` This renames the methods to use the `cast_` prefix instead of `as_` to make it more readable and avoid confusion with `<*mut T>::as_mut()` which is `unsafe` and returns a reference. Sorry, didn't notice ACP process exists, opened rust-lang/libs-team#51 See #92675
2 parents aa01891 + eb5acc9 commit ad31d5c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

library/core/src/ptr/const_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<T: ?Sized> *const T {
9797
/// refactored.
9898
#[unstable(feature = "ptr_const_cast", issue = "92675")]
9999
#[rustc_const_unstable(feature = "ptr_const_cast", issue = "92675")]
100-
pub const fn as_mut(self) -> *mut T {
100+
pub const fn cast_mut(self) -> *mut T {
101101
self as _
102102
}
103103

library/core/src/ptr/mut_ptr.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ impl<T: ?Sized> *mut T {
9696
/// refactored.
9797
///
9898
/// While not strictly required (`*mut T` coerces to `*const T`), this is provided for symmetry
99-
/// with `as_mut()` on `*const T` and may have documentation value if used instead of implicit
99+
/// with [`cast_mut`] on `*const T` and may have documentation value if used instead of implicit
100100
/// coercion.
101+
///
102+
/// [`cast_mut`]: #method.cast_mut
101103
#[unstable(feature = "ptr_const_cast", issue = "92675")]
102104
#[rustc_const_unstable(feature = "ptr_const_cast", issue = "92675")]
103-
pub const fn as_const(self) -> *const T {
105+
pub const fn cast_const(self) -> *const T {
104106
self as _
105107
}
106108

@@ -289,7 +291,7 @@ impl<T: ?Sized> *mut T {
289291
/// For the mutable counterpart see [`as_mut`].
290292
///
291293
/// [`as_uninit_ref`]: #method.as_uninit_ref-1
292-
/// [`as_mut`]: #method.as_mut-1
294+
/// [`as_mut`]: #method.as_mut
293295
///
294296
/// # Safety
295297
///

0 commit comments

Comments
 (0)