1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::{SliceMut, SliceRef, Soars};

/// Similar to `AsRef<Slice>`, but returns a value type rather than an
/// reference.
pub trait AsSlice {
    /// The type that the slice contains.
    type Item: Soars;

    /// Returns a [`SliceRef`] containing the entire array.
    fn as_slice(&self) -> SliceRef<'_, Self::Item>;
}

/// Similar to `AsMut<Slice>`, but returns a value type rather than a mutable
/// reference.
pub trait AsMutSlice: AsSlice {
    /// Returns a [`SliceMut`] containing the entire array.
    fn as_mut_slice(&mut self) -> SliceMut<'_, Self::Item>;
}