Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit678e5a0

Browse files
committed
Add "safety" comment
1 parent08f761f commit678e5a0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

‎core/src/slice/raw.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,16 @@ use crate::ub_checks;
9292
/// ```
9393
/// use std::slice;
9494
///
95+
/// /// # Safety
96+
/// ///
97+
/// /// If ptr is not NULL, it must be correctly aligned and
98+
/// /// point to `len` initialized items of type `f32`.
9599
/// unsafe extern "C" fn handle_slice(ptr: *const f32, len: usize) {
96100
/// let data = if ptr.is_null() {
97101
/// // `len` is assumed to be 0.
98102
/// &[]
99103
/// } else {
104+
/// // SAFETY: see function docstring.
100105
/// unsafe { slice::from_raw_parts(ptr, len) }
101106
/// };
102107
/// dbg!(data);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp