We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 08f761f commit 678e5a0Copy full SHA for 678e5a0
core/src/slice/raw.rs
@@ -92,11 +92,16 @@ use crate::ub_checks;
92
/// ```
93
/// use std::slice;
94
///
95
+/// /// # Safety
96
+/// ///
97
+/// /// If ptr is not NULL, it must be correctly aligned and
98
+/// /// point to `len` initialized items of type `f32`.
99
/// unsafe extern "C" fn handle_slice(ptr: *const f32, len: usize) {
100
/// let data = if ptr.is_null() {
101
/// // `len` is assumed to be 0.
102
/// &[]
103
/// } else {
104
+/// // SAFETY: see function docstring.
105
/// unsafe { slice::from_raw_parts(ptr, len) }
106
/// };
107
/// dbg!(data);
0 commit comments