[][src]Trait flatk::Isolate

pub trait Isolate<I> {
    type Output;
    fn try_isolate(self, idx: I) -> Option<Self::Output>;

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

Since we cannot alias mutable references, in order to index a mutable view of elements, we must consume the original mutable reference. Since we can't use slices for general composable collections, its impossible to match against a &mut self in the getter function to be able to use it with owned collections, so we opt to have an interface that is designed specifically for mutably borrowed collections. For composable collections, this is better described by a subview operator, which is precisely what this trait represents. Incidentally this can also work for owned collections, which is why it's called Isolate instead of SubView.

Associated Types

type Output

Loading content...

Required methods

fn try_isolate(self, idx: I) -> Option<Self::Output>

Loading content...

Provided methods

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.

Panics

This function will panic if self.get(idx) returns None.

Loading content...

Implementors

impl<S, I> Isolate<I> for S where
    I: IsolateIndex<Self>, 
[src]

A blanket implementation of Isolate for any collection which has an implementation for IsolateIndex.

type Output = I::Output

Loading content...