Skip to content

Commit 63cabff

Browse files
committed
document safety requirements on WeakArrayMut<'a, T, N>
1 parent 33c6a4c commit 63cabff

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

zlib-rs/src/weak_slice.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ pub(crate) struct WeakArrayMut<'a, T, const N: usize> {
7171
}
7272

7373
impl<'a, T, const N: usize> WeakArrayMut<'a, T, N> {
74+
/// # Safety
75+
///
76+
/// The arguments must satisfy the requirements of [`pointer::as_mut`]. The
77+
/// difference versus a `&mut [T; N]` is that the safety requirements are only enforced when a reference is
78+
/// needed, so in practice we mostly get the convenient slice APIs,
79+
/// without the exact correctness constraints of a rust core/std mutable reference.
80+
///
81+
/// [`pointer::as_mut`]: https://doc.rust-lang.org/core/primitive.pointer.html#method.as_mut
7482
pub(crate) unsafe fn from_ptr(ptr: *mut [T; N]) -> Self {
7583
Self {
7684
ptr,

0 commit comments

Comments
 (0)