about summary refs log tree commit diff
path: root/library/core/src/slice/raw.rs
diff options
context:
space:
mode:
authorMatthias Geier <Matthias.Geier@gmail.com>2024-04-26 20:44:59 +0200
committerMatthias Geier <Matthias.Geier@gmail.com>2024-04-26 20:44:59 +0200
commit22319bf6ba861eb0b5efb81aaf7616db30f4872f (patch)
tree19515d42b157b3e7a086cb3a0b1305d136f5f4e5 /library/core/src/slice/raw.rs
parent8e91a51cd81de5cf686d21db891634fecdc250c0 (diff)
downloadrust-22319bf6ba861eb0b5efb81aaf7616db30f4872f.tar.gz
rust-22319bf6ba861eb0b5efb81aaf7616db30f4872f.zip
Add "safety" comment
Diffstat (limited to 'library/core/src/slice/raw.rs')
-rw-r--r--library/core/src/slice/raw.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/core/src/slice/raw.rs b/library/core/src/slice/raw.rs
index d001688d79d..8ff429218a4 100644
--- a/library/core/src/slice/raw.rs
+++ b/library/core/src/slice/raw.rs
@@ -92,11 +92,16 @@ use crate::ub_checks;
 /// ```
 /// use std::slice;
 ///
+/// /// # Safety
+/// ///
+/// /// If ptr is not NULL, it must be correctly aligned and
+/// /// point to `len` initialized items of type `f32`.
 /// unsafe extern "C" fn handle_slice(ptr: *const f32, len: usize) {
 ///     let data = if ptr.is_null() {
 ///         // `len` is assumed to be 0.
 ///         &[]
 ///     } else {
+///         // SAFETY: see function docstring.
 ///         unsafe { slice::from_raw_parts(ptr, len) }
 ///     };
 ///     dbg!(data);