@@ -92,11 +92,16 @@ use crate::ub_checks; |
|
|
92 |
92 |
/// ``` |
93 |
93 |
/// use std::slice; |
94 |
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`. |
95 |
99 |
/// unsafe extern "C" fn handle_slice(ptr: *const f32, len: usize) { |
96 |
100 |
/// let data = if ptr.is_null() { |
97 |
101 |
/// // `len` is assumed to be 0. |
98 |
102 |
/// &[] |
99 |
103 |
/// } else { |
|
104 |
+/// // SAFETY: see function docstring. |
100 |
105 |
/// unsafe { slice::from_raw_parts(ptr, len) } |
101 |
106 |
/// }; |
102 |
107 |
/// dbg!(data); |