Compare commits

..

3 Commits

2 changed files with 19 additions and 1 deletions

View File

@ -8,4 +8,8 @@ license = "MIT"
keywords = ["memory", "slice", "array"] keywords = ["memory", "slice", "array"]
categories = ["data-structures"] categories = ["data-structures"]
repository = "https://git.nora.codes/nora/nslice" repository = "https://git.nora.codes/nora/nslice"
readme = "README.md"
[features]
nightly = []
default = ["nightly"]

View File

@ -83,6 +83,20 @@ impl<T, const N: usize> MinSlice<T, N> {
MinSlice::<T, M>::from_mut(self.as_mut_slice()) MinSlice::<T, M>::from_mut(self.as_mut_slice())
} }
/// Extend the `MinSlice`, returning a new `Some(&MinSlice<T, N + I>)`
/// if there are at least `I` `T`s in `tail`.
#[cfg(feature = "nightly")]
pub fn extend_by<const I: usize>(&self) -> Option<&MinSlice<T, {N + I}>> {
MinSlice::<T, {N + I}>::from_slice(self.as_slice())
}
/// Extend the `MinSlice`, returning a new `Some(&mut MinSlice<T, N + I>)`
/// if there are at least `I` `T`s in `tail`.
#[cfg(feature = "nightly")]
pub fn extend_by_mut<const I: usize>(&mut self) -> Option<&mut MinSlice<T, {N + I}>> {
MinSlice::<T, {N + I}>::from_mut(self.as_mut_slice())
}
/// Get a reference to a value from the `MinSlice` by index. /// Get a reference to a value from the `MinSlice` by index.
/// ///
/// Return `Some(&T)` for the `T` at index `i` if `i < (N + self.tail.len)`, /// Return `Some(&T)` for the `T` at index `i` if `i < (N + self.tail.len)`,