diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-08-21 19:56:46 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-11-06 11:04:42 +0100 |
| commit | 02f9167f94a06900ee555a5797081a44ebba009e (patch) | |
| tree | 78b13570e6846bdbe329d53347101c43d9825f07 /src/libcore/array/mod.rs | |
| parent | e8b190ac4ad79e58d21ee1d573529ff74d8eedaa (diff) | |
| download | rust-02f9167f94a06900ee555a5797081a44ebba009e.tar.gz rust-02f9167f94a06900ee555a5797081a44ebba009e.zip | |
Have tidy ensure that we document all `unsafe` blocks in libcore
Diffstat (limited to 'src/libcore/array/mod.rs')
| -rw-r--r-- | src/libcore/array/mod.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libcore/array/mod.rs b/src/libcore/array/mod.rs index e1ec8b795d0..74a7d062d3f 100644 --- a/src/libcore/array/mod.rs +++ b/src/libcore/array/mod.rs @@ -156,6 +156,7 @@ where fn try_from(slice: &[T]) -> Result<&[T; N], TryFromSliceError> { if slice.len() == N { let ptr = slice.as_ptr() as *const [T; N]; + // SAFETY: ok because we just checked that the length fits unsafe { Ok(&*ptr) } } else { Err(TryFromSliceError(())) @@ -173,6 +174,7 @@ where fn try_from(slice: &mut [T]) -> Result<&mut [T; N], TryFromSliceError> { if slice.len() == N { let ptr = slice.as_mut_ptr() as *mut [T; N]; + // SAFETY: ok because we just checked that the length fits unsafe { Ok(&mut *ptr) } } else { Err(TryFromSliceError(())) |
