Subset

Struct Subset 

Source
pub struct Subset<S, I = Box<[usize]>> { /* private fields */ }
Expand description

A Set that is a non-contiguous subset of some larger collection. B can be any borrowed collection type that implements the Set, and RemovePrefix traits. For iteration of subsets, the underlying type must also implement SplitFirst and SplitAt traits.

§Example

The following example shows how to create a Subset from a standard Vec.

use flatk::*;
let v = vec![1,2,3,4,5];
let subset = Subset::from_indices(vec![0,2,4], v.as_slice());
let mut subset_iter = subset.iter();
assert_eq!(Some(&1), subset_iter.next());
assert_eq!(Some(&3), subset_iter.next());
assert_eq!(Some(&5), subset_iter.next());
assert_eq!(None, subset_iter.next());

The next example shows how to create a Subset from a UniChunked collection.

use flatk::*;
let mut v = Chunked3::from_flat(vec![1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);
let mut subset = Subset::from_indices(vec![0,2,4], v.view_mut());
{
    let subset_view = subset.view();
    let mut subset_iter = subset_view.iter();
    assert_eq!(Some(&[1,2,3]), subset_iter.next());
    assert_eq!(Some(&[7,8,9]), subset_iter.next());
    assert_eq!(Some(&[13,14,15]), subset_iter.next());
    assert_eq!(None, subset_iter.next());
}
*subset.view_mut().isolate(1) = [0; 3];
assert_eq!(&[0,0,0], subset.view().at(1));

§Translation independence

This struct is very similar to Chunked, with the main difference being that each index corresponds to a single element instead of a chunk starting point.

Translation independence refers to the need to ensure that indices remain valid after splitting. When the indices are owned or mutably borrowed, we could simply modify the indices when we split the subset, but when the indices are a borrowed slice, this is not possible. To resolve this, we chop the part of data below the first index to ensure that the first index serves as an offset to the rest of the indices, making the entire index array translation independent.

Because Subsets modify the underlying data storage, it can often be misleading when querying the underlying data at any given time using one of Storage, StorageMut or StorageView traits.

For a more transparent data structure that preserves the original data set, use Select. To expose any characteristics of the contained data type, use a trait. See ChunkSize for an example.

Implementations§

Source§

impl<S, I> Subset<S, I>

Source

pub fn into_raw(self) -> (Option<I>, S)

Convert this subset into its internal representation.

Source

pub unsafe fn from_raw(indices: Option<I>, data: S) -> Subset<S, I>

Construct a subset from a set of indices and a data set.

Note that independent of the value of the indices, the first element in the subset will be the first element in data, and all subsequent elements are taken from data[index - first] for each index in indices where first is the first index appearing in indices.

§Safety

Constructing an invalid subset using this function isn’t itself unsafe, however calling various functions (except for Subset::validate) may be unsafe.

The given indices must be unique and in accending sorted order. All indices (minus the first) must be strictly less than the number of elements in data.

The Subset can be validated explicitly after creation using Subset::validate.

Source§

impl<S: Set + RemovePrefix> Subset<S, Vec<usize>>

Source

pub fn from_indices(indices: Vec<usize>, data: S) -> Self

Create a subset of elements from the original set given at the specified indices.

§Example
use flatk::*;
let v = vec![1,2,3];
let subset = Subset::from_indices(vec![0,2], v.as_slice());
assert_eq!(1, subset[0]);
assert_eq!(3, subset[1]);
Source§

impl<S: Set + RemovePrefix, I: AsRef<[usize]>> Subset<S, I>

Source

pub fn from_unique_ordered_indices(indices: I, data: S) -> Self

Create a subset of elements from the original collection corresponding to the given indices.

In contrast to Subset::from_indices, this function expects the indices to be unique and in sorted order, instead of manully making it so.

§Panics

This function panics when given a collection of unsorted indices. It also panics when indices are repeated.

§Example
use flatk::*;
let v = vec![0,1,2,3];
let indices = vec![1,3];

let subset_view = Subset::from_unique_ordered_indices(indices.as_slice(), v.as_slice());
assert_eq!(1, subset_view[0]);
assert_eq!(3, subset_view[1]);

let subset = Subset::from_unique_ordered_indices(indices, v.as_slice());
assert_eq!(1, subset[0]);
assert_eq!(3, subset[1]);
Source§

impl<S> Subset<S>

Source

pub fn all<I>(data: S) -> Subset<S, I>

Create a subset with all elements from the original set.

§Example
use flatk::*;
let subset = Subset::all::<Box<_>>(vec![1,2,3]);
let subset_view = subset.view();
let mut subset_iter = subset_view.iter();
assert_eq!(Some(&1), subset_iter.next());
assert_eq!(Some(&2), subset_iter.next());
assert_eq!(Some(&3), subset_iter.next());
assert_eq!(None, subset_iter.next());
Source

pub fn all_def(data: S) -> Subset<S>

Create a subset with all elements from the original set.

This version of all creates the Subset type with the default index type, since it cannot be determined from the function arguments. In other words this function doesn’t require an additional generic parameter to be specified when the return type is ambiguous.

§Example
use flatk::*;
let subset = Subset::all_def(vec![1,2,3]);
let subset_view = subset.view();
let mut subset_iter = subset_view.iter();
assert_eq!(Some(&1), subset_iter.next());
assert_eq!(Some(&2), subset_iter.next());
assert_eq!(Some(&3), subset_iter.next());
assert_eq!(None, subset_iter.next());
Source§

impl<S: Set, I: AsRef<[usize]>> Subset<S, I>

Source

pub fn find_by_index(&self, index: usize) -> Option<usize>

Find an element in the subset by its index in the superset. Return the index of the element in the subset if found. Since subset indices are always in sorted order, this function performs a binary search.

§Examples

In the following simple example the element 3 is found at superset index 2 which is located at index 1 in the subset.

use flatk::*;
let superset =  vec![1,2,3,4,5,6];
let subset = Subset::from_unique_ordered_indices(vec![1,2,5], superset);
assert_eq!(Some(1), subset.find_by_index(2));
assert_eq!(None, subset.find_by_index(3));

Note that the superset index refers to the indices with which the subset was created. This means that even after we have split the subset, the input indices are expected to refer to the original subset. The following example demonstrates this by splitting the original subset in the pervious example.

use flatk::*;
let superset =  vec![1,2,3,4,5,6];
let subset = Subset::from_unique_ordered_indices(vec![1,2,5], superset);
let (_, r) = subset.view().split_at(1);
assert_eq!(Some(0), r.find_by_index(2));
assert_eq!(None, r.find_by_index(3));
Source§

impl<'a, S: Set, I> Subset<S, I>

Source

pub fn indices(&self) -> Option<&I>

Get a references to the underlying indices. If None is returned, then this subset spans the entire domain data.

Source

pub fn into_super(self) -> S

Return the superset of this Subset. This is just the set it was created with.

Source§

impl<'a, S, I> Subset<S, I>
where Self: Set + ViewIterator<'a>,

Source

pub fn clone_into_other<V>(&'a self, other: &'a mut V)
where V: Set + ViewMutIterator<'a> + ?Sized, <Self as ViewIterator<'a>>::Item: CloneIntoOther<<V as ViewMutIterator<'a>>::Item>,

The typical way to use this function is to clone from a SubsetView into an owned S type.

§Panics

This function panics if other has a length unequal to self.len().

§Example
use flatk::*;
let v = vec![1,2,3,4,5];
let indices = vec![0,2,4];
let subset = Subset::from_unique_ordered_indices(indices.as_slice(), v.as_slice());
let mut owned = vec![0; 4];
subset.clone_into_other(&mut owned[..3]); // Need 3 elements to avoid panics.
let mut iter_owned = owned.iter();
assert_eq!(owned, vec![1,3,5,0]);
Source§

impl<'a, S, I> Subset<S, I>
where S: Set + View<'a>, I: AsRef<[usize]>,

Source

pub fn iter(&'a self) -> SubsetIter<S::Type, &'a [usize]>

Immutably iterate over a borrowed subset.

§Example
use flatk::*;
let mut v = vec![1,2,3,4,5];
let mut subset = Subset::from_indices(vec![0,2,4], v.as_mut_slice());
let mut iter = subset.iter();
assert_eq!(Some(&1), iter.next());
assert_eq!(Some(&3), iter.next());
assert_eq!(Some(&5), iter.next());
assert_eq!(None, iter.next());
Source

pub fn index_iter(&'a self) -> SubsetIndexIter<'a>

Immutably iterate over the indices stored by this subset.

The returned indices point to the superset from which this subset was created.

§Example
use flatk::*;
let mut v = vec![1,2,3,4,5];
let mut subset = Subset::from_indices(vec![0,2,4], v.as_mut_slice());
let mut iter = subset.index_iter();
assert_eq!(Some(0), iter.next());
assert_eq!(Some(2), iter.next());
assert_eq!(Some(4), iter.next());
assert_eq!(None, iter.next());

This also works if the subset is entire:

use flatk::*;
let mut v = vec![1,2,3,4,5];
let mut subset = Subset::all_def(v.as_slice());
let mut iter = subset.index_iter();
assert_eq!(Some(0), iter.next());
assert_eq!(Some(3), iter.nth(2));
assert_eq!(Some(4), iter.next());
assert_eq!(None, iter.next());
Source§

impl<'a, S, I> Subset<S, I>
where S: Set + ViewMut<'a>, I: AsRef<[usize]>,

Source

pub fn iter_mut( &'a mut self, ) -> SubsetIter<<S as ViewMut<'a>>::Type, &'a [usize]>

Mutably iterate over a borrowed subset.

§Example
use flatk::*;
let mut v = vec![1,2,3,4,5];
let mut subset = Subset::from_indices(vec![0,2,4], v.as_mut_slice());
for i in subset.iter_mut() {
    *i += 1;
}
assert_eq!(v, vec![2,2,4,4,6]);
Source§

impl<S: ChunkSize, I, N: Dimension> Subset<UniChunked<S, N>, I>

Source

pub fn inner_chunk_size(&self) -> usize

Trait Implementations§

Source§

impl<S: ChunkSize, I> ChunkSize for Subset<S, I>

Source§

impl<S: Clone, I: Clone> Clone for Subset<S, I>

Source§

fn clone(&self) -> Subset<S, I>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug, I: Debug> Debug for Subset<S, I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: Dummy, I> Dummy for Subset<S, I>

Source§

unsafe fn dummy() -> Self

Constructs a potentially invalid instance of a type. Read more
Source§

impl<'a, S, O> GetIndex<'a, Subset<S, O>> for &usize
where O: AsRef<[usize]>, S: Get<'a, usize>,

Source§

type Output = <S as Get<'a, usize>>::Output

Source§

fn get(self, subset: &Subset<S, O>) -> Option<Self::Output>

Gets the value in the set at this index.
Source§

unsafe fn at_unchecked(self, set: &S) -> Self::Output
where Self: Sized,

Gets the value in the set at this index. Read more
Source§

impl<'a, S, O> GetIndex<'a, Subset<S, O>> for usize
where O: AsRef<[usize]>, S: Get<'a, usize>,

Source§

type Output = <S as Get<'a, usize>>::Output

Source§

fn get(self, subset: &Subset<S, O>) -> Option<Self::Output>

Gets the value in the set at this index.
Source§

unsafe fn at_unchecked(self, set: &S) -> Self::Output
where Self: Sized,

Gets the value in the set at this index. Read more
Source§

impl<'a, T, I> Index<usize> for Subset<&'a [T], I>
where I: AsRef<[usize]>,

Source§

fn index(&self, idx: usize) -> &Self::Output

Immutably index the subset.

§Panics

This function panics if the index is out of bounds or if the subset is empty.

§Example
use flatk::*;
let v = vec![1,2,3,4,5];
let subset = Subset::from_indices(vec![0,2,4], v.as_slice());
assert_eq!(3, subset[1]);
Source§

type Output = T

The returned type after indexing.
Source§

impl<'a, T, I> Index<usize> for Subset<&'a mut [T], I>
where I: AsRef<[usize]>,

Source§

fn index(&self, idx: usize) -> &Self::Output

Immutably index the subset.

§Panics

This function panics if the index is out of bounds or if the subset is empty.

§Example
use flatk::*;
let mut v = vec![1,2,3,4,5];
let mut subset = Subset::from_indices(vec![0,2,4], v.as_mut_slice());
assert_eq!(3, subset[1]);
Source§

type Output = T

The returned type after indexing.
Source§

impl<'a, S, I> Index<usize> for Subset<S, I>
where S: Index<usize> + Set + ValueType, I: AsRef<[usize]>,

Source§

fn index(&self, idx: usize) -> &Self::Output

Immutably index the subset.

§Panics

This function panics if the index is out of bounds or if the subset is empty.

§Example
use flatk::*;
let c = Chunked2::from_flat((1..=12).collect::<Vec<_>>());
let subset = Subset::from_indices(vec![0,2,4], c.view());
assert_eq!([1,2], subset[0]);
assert_eq!([5,6], subset[1]);
assert_eq!([9,10], subset[2]);
Source§

type Output = <S as Index<usize>>::Output

The returned type after indexing.
Source§

impl<'a, T, I> IndexMut<usize> for Subset<&'a mut [T], I>
where I: AsRef<[usize]>,

Source§

fn index_mut(&mut self, idx: usize) -> &mut Self::Output

Mutably index the subset.

§Panics

This function panics if the index is out of bounds or if the subset is empty.

§Example
use flatk::*;
let mut v = vec![1,2,3,4,5];
let mut subset = Subset::from_indices(vec![0,2,4], v.as_mut_slice());
assert_eq!(subset[1], 3);
subset[1] = 100;
assert_eq!(subset[0], 1);
assert_eq!(subset[1], 100);
assert_eq!(subset[2], 5);
Source§

impl<'a, S, I> IndexMut<usize> for Subset<S, I>
where S: IndexMut<usize> + Set + ValueType, I: AsRef<[usize]>,

Source§

fn index_mut(&mut self, idx: usize) -> &mut Self::Output

Mutably index the subset.

§Panics

This function panics if the index is out of bounds or if the subset is empty.

§Example
use flatk::*;
let mut v = vec![1,2,3,4,5];
let mut subset = Subset::from_indices(vec![0,2,4], v.as_mut_slice());
assert_eq!(subset[1], 3);
subset[1] = 100;
assert_eq!(subset[0], 1);
assert_eq!(subset[1], 100);
assert_eq!(subset[2], 5);
Source§

impl<S, I> IntoIterator for Subset<S, I>

Source§

fn into_iter(self) -> Self::IntoIter

Convert a Subset into an iterator.

§Example
use flatk::*;
let mut s = Subset::from_unique_ordered_indices(vec![1,3,5], vec![1,2,3,4,5,6]);
let mut iter = s.view().into_iter();
assert_eq!(Some(&2), iter.next());
assert_eq!(Some(&4), iter.next());
assert_eq!(Some(&6), iter.next());
assert_eq!(None, iter.next());
Source§

type Item = <S as SplitFirst>::First

The type of the elements being iterated over.
Source§

type IntoIter = SubsetIter<S, I>

Which kind of iterator are we turning this into?
Source§

impl<S: IntoOwned, I: IntoOwned> IntoOwned for Subset<S, I>

Source§

type Owned = Subset<<S as IntoOwned>::Owned, <I as IntoOwned>::Owned>

Source§

fn into_owned(self) -> Self::Owned

Source§

fn clone_into(self, target: &mut Self::Owned)

Source§

impl<S, I> IntoOwnedData for Subset<S, I>
where S: IntoOwnedData,

Source§

type OwnedData = Subset<<S as IntoOwnedData>::OwnedData, I>

Source§

fn into_owned_data(self) -> Self::OwnedData

Source§

fn clone_into(self, target: &mut Self::OwnedData)

Source§

impl<S, O, N: Unsigned> IsolateIndex<Subset<S, O>> for StaticRange<N>
where Range<usize>: IsolateIndex<Subset<S, O>>,

Source§

type Output = <Range<usize> as IsolateIndex<Subset<S, O>>>::Output

Source§

unsafe fn isolate_unchecked(self, set: Subset<S, O>) -> Self::Output

Attempts to isolate a value in the given set at this index. Read more
Source§

fn try_isolate(self, set: Subset<S, O>) -> Option<Self::Output>

Attempts to isolate a value in the given set at this index. Read more
Source§

impl<S, O> IsolateIndex<Subset<S, O>> for usize
where O: AsRef<[usize]>, S: Isolate<usize>,

Source§

type Output = <S as Isolate<usize>>::Output

Source§

unsafe fn isolate_unchecked(self, subset: Subset<S, O>) -> Self::Output

Attempts to isolate a value in the given set at this index. Read more
Source§

fn try_isolate(self, subset: Subset<S, O>) -> Option<Self::Output>

Attempts to isolate a value in the given set at this index. Read more
Source§

impl<S: MapStorage<Out>, I, Out> MapStorage<Out> for Subset<S, I>

Source§

type Input = <S as MapStorage<Out>>::Input

Source§

type Output = Subset<<S as MapStorage<Out>>::Output, I>

Source§

fn map_storage<F: FnOnce(Self::Input) -> Out>(self, f: F) -> Self::Output

Source§

impl<S: PartialEq, I: PartialEq> PartialEq for Subset<S, I>

Source§

fn eq(&self, other: &Subset<S, I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Set + RemovePrefix, I: RemovePrefix + AsRef<[usize]>> RemovePrefix for Subset<S, I>

Source§

fn remove_prefix(&mut self, n: usize)

This function will panic if n is larger than self.len().

Source§

impl<S: Set, I: AsRef<[usize]>> Set for Subset<S, I>

Required for Chunked and UniChunked subsets.

Source§

fn len(&self) -> usize

Get the length of this subset.

§Example
use flatk::*;
let v = vec![1,2,3,4,5];
let subset = Subset::from_indices(vec![0,2,4], v.as_slice());
assert_eq!(3, subset.len());
Source§

type Elem = <S as Set>::Elem

Owned element of the set.
Source§

type Atom = <S as Set>::Atom

The most basic element contained by this collection. If this collection contains other collections, this type should be different than Elem.
Source§

fn is_empty(&self) -> bool

Source§

impl<S, I> SplitFirst for Subset<S, I>

This impl enables Subsets of Subsets

Source§

fn split_first(self) -> Option<(Self::First, Self)>

Split the first element of this subset.

Source§

type First = <S as SplitFirst>::First

Source§

unsafe fn split_first_unchecked(self) -> (Self::First, Self)

Split off the first element without checking if one exists. Read more
Source§

impl<S: Storage, I> Storage for Subset<S, I>

Source§

fn storage(&self) -> &Self::Storage

Return an immutable reference to the underlying storage type.

§Example
use flatk::*;
let v = vec![1,2,3,4,5,6,7,8,9,10,11,12];
let s0 = Chunked3::from_flat(v.clone());
let s1 = Subset::from_indices(vec![0, 2, 3], s0.clone());
assert_eq!(s1.storage(), &v);
Source§

type Storage = <S as Storage>::Storage

Source§

impl<S: StorageInto<T>, I, T> StorageInto<T> for Subset<S, I>

Pass through the conversion for structure type Subset.

Source§

type Output = Subset<<S as StorageInto<T>>::Output, I>

Source§

fn storage_into(self) -> Self::Output

Source§

impl<S: StorageMut, I> StorageMut for Subset<S, I>

Source§

fn storage_mut(&mut self) -> &mut Self::Storage

Return a mutable reference to the underlying storage type.

§Example
use flatk::*;
let mut v = vec![1,2,3,4,5,6,7,8,9,10,11,12];
let mut s0 = Chunked3::from_flat(v.clone());
let mut s1 = Subset::from_indices(vec![0, 2, 3], s0.clone());
assert_eq!(s1.storage_mut(), &mut v);
Source§

impl<'a, S: StorageView<'a>, I> StorageView<'a> for Subset<S, I>

Source§

fn storage_view(&'a self) -> Self::StorageView

Return a view to the underlying storage type.

§Example
use flatk::*;
let v = vec![1,2,3,4,5,6,7,8,9,10,11,12];
let s0 = Chunked3::from_flat(v.clone());
let s1 = Subset::from_indices(vec![0, 2, 3], s0.clone());
assert_eq!(s1.storage_view(), v.as_slice());
Source§

type StorageView = <S as StorageView<'a>>::StorageView

Source§

impl<S: Truncate, I: Truncate> Truncate for Subset<S, I>

Source§

fn truncate(&mut self, new_len: usize)

Source§

impl<S, I, M> UniChunkable<M> for Subset<S, I>

Source§

type Chunk = Subset<S, I>

Source§

impl<'a, S, I> View<'a> for Subset<S, I>
where S: View<'a>, I: AsRef<[usize]>,

Required for Chunked and UniChunked subsets.

Source§

type Type = Subset<<S as View<'a>>::Type, &'a [usize]>

Source§

fn view(&'a self) -> Self::Type

Source§

impl<'a, S, I> ViewIterator<'a> for Subset<S, I>
where S: Set + View<'a>, I: AsRef<[usize]>, <S as View<'a>>::Type: SplitAt + SplitFirst + Set + Dummy,

Source§

type Item = <<S as View<'a>>::Type as SplitFirst>::First

Source§

type Iter = SubsetIter<<S as View<'a>>::Type, &'a [usize]>

Source§

fn view_iter(&'a self) -> Self::Iter

Source§

impl<'a, S, I> ViewMut<'a> for Subset<S, I>
where S: ViewMut<'a>, I: AsRef<[usize]>,

Source§

fn view_mut(&'a mut self) -> Self::Type

Create a mutable view into this subset.

§Example
use flatk::*;
let mut v = vec![1,2,3,4,5];
let mut subset = Subset::from_indices(vec![0,2,4], v.as_mut_slice());
let mut view = subset.view_mut();
for i in view.iter_mut() {
    *i += 1;
}
assert_eq!(v, vec![2,2,4,4,6]);
Source§

type Type = Subset<<S as ViewMut<'a>>::Type, &'a [usize]>

Source§

impl<'a, S, I> ViewMutIterator<'a> for Subset<S, I>
where S: Set + ViewMut<'a>, I: AsRef<[usize]>, <S as ViewMut<'a>>::Type: SplitAt + SplitFirst + Set + Dummy,

Source§

type Item = <<S as ViewMut<'a>>::Type as SplitFirst>::First

Source§

type Iter = SubsetIter<<S as ViewMut<'a>>::Type, &'a [usize]>

Source§

fn view_mut_iter(&'a mut self) -> Self::Iter

Source§

impl<S: Copy, I: Copy> Copy for Subset<S, I>

Source§

impl<S, I> DynamicRangeIndexType for Subset<S, I>

Source§

impl<S, I> StructuralPartialEq for Subset<S, I>

Source§

impl<S, I> ValueType for Subset<S, I>

Source§

impl<S: Viewed, I: Viewed> Viewed for Subset<S, I>

Auto Trait Implementations§

§

impl<S, I> Freeze for Subset<S, I>
where S: Freeze, I: Freeze,

§

impl<S, I> RefUnwindSafe for Subset<S, I>

§

impl<S, I> Send for Subset<S, I>
where S: Send, I: Send,

§

impl<S, I> Sync for Subset<S, I>
where S: Sync, I: Sync,

§

impl<S, I> Unpin for Subset<S, I>
where S: Unpin, I: Unpin,

§

impl<S, I> UnwindSafe for Subset<S, I>
where S: UnwindSafe, I: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, S, I> Get<'a, I> for S
where I: GetIndex<'a, S>,

Source§

type Output = <I as GetIndex<'a, S>>::Output

Source§

fn get(&self, idx: I) -> Option<<I as GetIndex<'a, S>>::Output>

Source§

fn at(&self, idx: I) -> Self::Output

Return a value at the given index. This is provided as the checked version of get that will panic if the equivalent get call is None, which typically means that the given index is out of bounds. Read more
Source§

unsafe fn at_unchecked(&self, idx: I) -> Self::Output

Return a value at the given index. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<S> IntoChunkIterator for S
where S: Set + SplitAt + Dummy,

Source§

type Item = S

Source§

type IterType = ChunkedNIter<S>

Source§

fn into_chunk_iter( self, chunk_size: usize, ) -> <S as IntoChunkIterator>::IterType

Produce a chunk iterator with the given stride chunk_size. One notable difference between this trait and chunks* methods on slices is that chunks_iter should panic when the underlying data cannot split into chunk_size sized chunks exactly.
Source§

impl<S, I> Isolate<I> for S
where I: IsolateIndex<S>,

Source§

type Output = <I as IsolateIndex<S>>::Output

Source§

unsafe fn isolate_unchecked(self, idx: I) -> <S as Isolate<I>>::Output

Unchecked version of isolate. Read more
Source§

fn try_isolate(self, idx: I) -> Option<<S as Isolate<I>>::Output>

Source§

fn isolate(self, idx: I) -> Self::Output
where Self: Sized,

Return a value at the given index. This is provided as the checked version of try_isolate that will panic if the equivalent try_isolate call is None, which typically means that the given index is out of bounds. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, N> PushArrayToVec<N> for T
where T: Clone, N: Array<T>,

Source§

fn push_to_vec(element: <N as Array<T>>::Array, set: &mut Vec<T>)

This method tells this type how it can be pushed to a Vec as an array.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.