Skip to content

Commit

Permalink
Remove #[doc(hidden)] from various functions
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Dec 26, 2023
1 parent 6a3618d commit e2ce8c2
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 41 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved `Array` documentation
- Add store testing utility functions for unified store testing
- Make various `Array` methods with `parallel` parameter `pub`
- Remove `#[doc(hidden)]` from various functions which are `unsafe` and primarily intended for internal use

### Fixed
- Fixed `MemoryStore::get_partial_values_key` if given an invalid byte range, now returns `InvalidByteRangeError` instead of panicking
Expand Down
5 changes: 2 additions & 3 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ impl<TStorage: ?Sized> Array<TStorage> {
}

// Safe transmute, avoiding an allocation where possible
// https://github.com/nabijaczleweli/safe-transmute-rs/issues/16#issuecomment-471066699
//
// A relevant discussion about this can be found here: https://github.com/nabijaczleweli/safe-transmute-rs/issues/16#issuecomment-471066699
#[doc(hidden)]
#[must_use]
pub fn safe_transmute_to_bytes_vec<T: TriviallyTransmutable>(mut from: Vec<T>) -> Vec<u8> {
Expand Down Expand Up @@ -585,7 +586,6 @@ pub fn safe_transmute_to_bytes_vec<T: TriviallyTransmutable>(mut from: Vec<T>) -
}

/// Unravel a linearised index to ND indices.
#[doc(hidden)]
#[must_use]
pub fn unravel_index(mut index: u64, shape: &[u64]) -> ArrayIndices {
let len = shape.len();
Expand All @@ -601,7 +601,6 @@ pub fn unravel_index(mut index: u64, shape: &[u64]) -> ArrayIndices {
}

/// Ravel ND indices to a linearised index.
#[doc(hidden)]
#[must_use]
pub fn ravel_indices(indices: &[u64], shape: &[u64]) -> u64 {
let mut index: u64 = 0;
Expand Down
2 changes: 0 additions & 2 deletions src/array/array_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ impl ArrayRepresentation {
/// Create a new [`ArrayRepresentation`].
///
/// # Safety
///
/// `data_type` and `fill_value` must be compatible.
#[doc(hidden)]
#[must_use]
pub unsafe fn new_unchecked(
array_shape: ArrayShape,
Expand Down
7 changes: 0 additions & 7 deletions src/array/chunk_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,9 @@ pub trait ChunkGridTraits: dyn_clone::DynClone + core::fmt::Debug + Send + Sync
})
}

#[doc(hidden)]
/// See [`ChunkGridTraits::grid_shape`].
///
/// # Safety
///
/// The length of `array_shape` must match the dimensionality of the chunk grid.
unsafe fn grid_shape_unchecked(&self, array_shape: &[u64]) -> Option<ArrayShape>;

Expand All @@ -270,19 +268,16 @@ pub trait ChunkGridTraits: dyn_clone::DynClone + core::fmt::Debug + Send + Sync
array_shape: &[u64],
) -> Option<ArrayIndices>;

#[doc(hidden)]
/// See [`ChunkGridTraits::chunk_shape`].
///
/// # Safety
///
/// The length of `chunk_indices` must match the dimensionality of the chunk grid.
unsafe fn chunk_shape_unchecked(
&self,
chunk_indices: &[u64],
array_shape: &[u64],
) -> Option<ArrayShape>;

#[doc(hidden)]
/// See [`ChunkGridTraits::chunk_indices`].
///
/// # Safety
Expand All @@ -293,7 +288,6 @@ pub trait ChunkGridTraits: dyn_clone::DynClone + core::fmt::Debug + Send + Sync
array_shape: &[u64],
) -> Option<ArrayIndices>;

#[doc(hidden)]
/// See [`ChunkGridTraits::chunk_element_indices`].
///
/// # Safety
Expand All @@ -304,7 +298,6 @@ pub trait ChunkGridTraits: dyn_clone::DynClone + core::fmt::Debug + Send + Sync
array_shape: &[u64],
) -> Option<ArrayIndices>;

#[doc(hidden)]
/// See [`ChunkGridTraits::subset`].
///
/// # Safety
Expand Down
26 changes: 0 additions & 26 deletions src/array_subset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ impl ArraySubset {
/// Create a new array subset.
///
/// # Safety
///
/// The length of `start` and `size` must match.
#[doc(hidden)]
#[must_use]
pub unsafe fn new_with_start_shape_unchecked(start: ArrayIndices, shape: ArrayShape) -> Self {
debug_assert_eq!(start.len(), shape.len());
Expand All @@ -127,9 +125,7 @@ impl ArraySubset {
/// Create a new array subset from a start and end (inclusive).
///
/// # Safety
///
/// The length of `start` and `end` must match.
#[doc(hidden)]
#[must_use]
pub unsafe fn new_with_start_end_inc_unchecked(start: ArrayIndices, end: ArrayIndices) -> Self {
debug_assert_eq!(start.len(), end.len());
Expand Down Expand Up @@ -161,9 +157,7 @@ impl ArraySubset {
/// Create a new array subset from a start and end (exclusive).
///
/// # Safety
///
/// The length of `start` and `end` must match.
#[doc(hidden)]
#[must_use]
pub unsafe fn new_with_start_end_exc_unchecked(start: ArrayIndices, end: ArrayIndices) -> Self {
debug_assert_eq!(start.len(), end.len());
Expand Down Expand Up @@ -282,9 +276,7 @@ impl ArraySubset {
/// Return the byte ranges of an array subset in an array with `array_shape` and `element_size`.
///
/// # Safety
///
/// The length of `array_shape` must match the dimensionality of `array_subset`.
#[doc(hidden)]
#[must_use]
pub unsafe fn byte_ranges_unchecked(
&self,
Expand Down Expand Up @@ -339,13 +331,10 @@ impl ArraySubset {
/// Return the bytes in this array subset from an array with shape `array_shape` and `element_size`.
///
/// # Safety
///
/// The length of `array_shape` must match the array subset dimensionality and the array subset must be within the bounds of `array_shape`.
///
/// # Panics
///
/// Panics if attempting to reference a byte beyond `usize::MAX`.
#[doc(hidden)]
#[must_use]
pub unsafe fn extract_bytes_unchecked(
&self,
Expand Down Expand Up @@ -417,13 +406,10 @@ impl ArraySubset {
/// Return the elements in this array subset from an array with shape `array_shape`.
///
/// # Safety
///
/// The length of `array_shape` must match the array subset dimensionality and the array subset must be within the bounds of `array_shape`.
///
/// # Panics
///
/// Panics if attempting to reference a byte beyond `usize::MAX`.
#[doc(hidden)]
#[must_use]
pub unsafe fn extract_elements_unchecked<T: std::marker::Copy>(
&self,
Expand Down Expand Up @@ -569,9 +555,7 @@ impl ArraySubset {
/// Returns an iterator over the indices of elements within the subset.
///
/// # Safety
///
/// `array_shape` must match the dimensionality and encapsulate this array subset.
#[doc(hidden)]
#[must_use]
pub unsafe fn iter_linearised_indices_unchecked<'a>(
&'a self,
Expand All @@ -595,9 +579,7 @@ impl ArraySubset {
/// Returns an iterator over the indices of contiguous elements within the subset.
///
/// # Safety
///
/// The length of `array_shape` must match the array subset dimensionality.
#[doc(hidden)]
#[must_use]
pub unsafe fn iter_contiguous_indices_unchecked<'a>(
&'a self,
Expand All @@ -621,9 +603,7 @@ impl ArraySubset {
/// Returns an iterator over the linearised indices of contiguous elements within the subset.
///
/// # Safety
///
/// The length of `array_shape` must match the array subset dimensionality.
#[doc(hidden)]
#[must_use]
pub unsafe fn iter_contiguous_linearised_indices_unchecked<'a>(
&'a self,
Expand Down Expand Up @@ -653,9 +633,7 @@ impl ArraySubset {
/// Thus, the subsets of the chunks may extend out over the subset.
///
/// # Safety
///
/// The length of `chunk_shape` must match the array subset dimensionality.
#[doc(hidden)]
#[must_use]
pub unsafe fn iter_chunks_unchecked<'a>(&'a self, chunk_shape: &'a [u64]) -> ChunksIterator {
ChunksIterator::new_unchecked(self, chunk_shape)
Expand Down Expand Up @@ -691,9 +669,7 @@ impl ArraySubset {
/// The start of the returned array subset is from the start of this array subset.
///
/// # Safety
///
/// Panics if the dimensionality of `subset_other` does not match the dimensionality of this array subset.
#[doc(hidden)]
#[must_use]
pub unsafe fn in_subset_unchecked(&self, subset_other: &Self) -> Self {
debug_assert_eq!(subset_other.dimensionality(), self.dimensionality());
Expand Down Expand Up @@ -731,9 +707,7 @@ impl ArraySubset {
/// Return the overlapping subset between this array subset and `subset_other`.
///
/// # Safety
///
/// Panics if the dimensionality of `subset_other` does not match the dimensionality of this array subset.
#[doc(hidden)]
#[must_use]
pub unsafe fn overlap_unchecked(&self, subset_other: &Self) -> Self {
debug_assert_eq!(subset_other.dimensionality(), self.dimensionality());
Expand Down
5 changes: 2 additions & 3 deletions src/byte_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ fn validate_byte_ranges(byte_ranges: &[ByteRange], bytes_len: u64) -> bool {
/// Extract byte ranges from bytes.
///
/// # Errors
///
/// Returns [`InvalidByteRangeError`] if any bytes are requested beyond the end of `bytes`.
pub fn extract_byte_ranges(
bytes: &[u8],
Expand All @@ -126,10 +125,10 @@ pub fn extract_byte_ranges(
/// Extract byte ranges from bytes.
///
/// # Safety
///
/// All byte ranges in `byte_ranges` must specify a range within `bytes`.
///
#[doc(hidden)]
/// # Panics
/// Panics if attempting to reference a byte beyond `usize::MAX`.
#[must_use]
pub unsafe fn extract_byte_ranges_unchecked(
bytes: &[u8],
Expand Down

0 comments on commit e2ce8c2

Please sign in to comment.