Skip to content

Commit 5885e6d

Browse files
authored
Rollup merge of #97565 - lukas-code:patch-1, r=thomcc
Add doc alias `memset` to `write_bytes` I were looking for `memset` in rust, but the docs only pointed me to `slice::fill`. With only the old aliases, one might write code like this, which is incorrect if the memory is uninitialized. ``` Rust core::slice::from_raw_parts(ptr, len).fill(0) ```
2 parents bf248c8 + e565bb0 commit 5885e6d

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

library/core/src/intrinsics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2287,6 +2287,7 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
22872287
/// // Now the box is fine
22882288
/// assert_eq!(*v, 42);
22892289
/// ```
2290+
#[doc(alias = "memset")]
22902291
#[stable(feature = "rust1", since = "1.0.0")]
22912292
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
22922293
#[inline]

library/core/src/ptr/mut_ptr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,7 @@ impl<T: ?Sized> *mut T {
14121412
/// See [`ptr::write_bytes`] for safety concerns and examples.
14131413
///
14141414
/// [`ptr::write_bytes`]: crate::ptr::write_bytes()
1415+
#[doc(alias = "memset")]
14151416
#[stable(feature = "pointer_methods", since = "1.26.0")]
14161417
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
14171418
#[inline(always)]

0 commit comments

Comments
 (0)