Skip to content

Commit 14ab554

Browse files
committed
docs: add safety comments for two unsafe functions. added #allow(missing_docs) for two functions (next_in_dim & next_out_dim) in slice.rs
1 parent eb930de commit 14ab554

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,13 +676,13 @@ pub trait SliceNextDim
676676
type InDim: Dimension;
677677
/// Number of dimensions that this slicing argument produces in the output array.
678678
type OutDim: Dimension;
679-
679+
#[allow(missing_docs)]
680680
fn next_in_dim<D>(&self, _: PhantomData<D>) -> PhantomData<<D as DimAdd<Self::InDim>>::Output>
681681
where D: Dimension + DimAdd<Self::InDim>
682682
{
683683
PhantomData
684684
}
685-
685+
#[allow(missing_docs)]
686686
fn next_out_dim<D>(&self, _: PhantomData<D>) -> PhantomData<<D as DimAdd<Self::OutDim>>::Output>
687687
where D: Dimension + DimAdd<Self::OutDim>
688688
{

src/zip/ndproducer.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,20 @@ pub trait NdProducer
8181
}
8282
/// Returns a pointer to the first element of the data.
8383
fn as_ptr(&self) -> Self::Ptr;
84-
/// Dereferences the pointer to get a reference to the element.
84+
/// Dereferences the pointer to get a mutable reference to the element.
85+
///
86+
/// # Safety
87+
///
88+
/// `ptr` must be a valid pointer obtained from this producer and must point
89+
/// to an initialized element within the data's bounds. Additionally, there
90+
/// must be no other references (mutable or immutable) to this element.
8591
unsafe fn as_ref(&self, ptr: Self::Ptr) -> Self::Item;
86-
/// Returns a pointer to the element at the given index without bounds checking.
92+
/// Dereferences the pointer to get a mutable reference to the element.
93+
///
94+
/// # Safety
95+
///
96+
/// `ptr` must be a valid, aligned pointer obtained from this producer, pointing
97+
/// to an initialized element within the data's bounds with exclusive access.
8798
unsafe fn uget_ptr(&self, i: &Self::Dim) -> Self::Ptr;
8899
/// Returns the stride (offset between elements) along the specified axis.
89100
fn stride_of(&self, axis: Axis) -> <Self::Ptr as Offset>::Stride;

0 commit comments

Comments
 (0)