[][src]Struct treeflection::context_vec::ContextVec

pub struct ContextVec<T> { /* fields omitted */ }

Implementations

impl<T> ContextVec<T>[src]

The purpose of a ContextVec is to provide a way for commands to easily access relevant values. If we have a ContextVec named foo, the command foo[?] get will display the values in foo that the context points to.

Contents

  • vector: Vec<T>
  • context: Vec<usize>

Invariants

  • the values in context will point to a valid value in vector
  • the values in context will continue to point to the same value in vector (even after operations like insert and remove)

pub fn new() -> ContextVec<T>[src]

Create a new empty ContextVec

pub fn from_vec(vector: Vec<T>) -> ContextVec<T>[src]

Create a new ContextVec from a Vec

pub fn selection_first(&self) -> Option<&T>[src]

Get the value currently pointed to by context

pub fn selection_first_mut(&mut self) -> Option<&mut T>[src]

Mutably get the value currently pointed to by context

pub fn selection(&self) -> Vec<&T>[src]

Get the values currently pointed to by context

pub fn get_context(&self) -> &[usize][src]

Get a slice of the context

pub fn into_context(self) -> Vec<usize>[src]

Consume the ContextVec into the context

pub fn into_vector(self) -> Vec<T>[src]

Consume the ContextVec into the vector

pub fn into_tuple(self) -> (Vec<usize>, Vec<T>)[src]

Consume the ContextVec into a tuple of the context and the vector

pub fn clear_context(&mut self)[src]

Clears the context

pub fn set_context(&mut self, value: usize)[src]

Sets a new context

pub fn set_context_vec(&mut self, values: Vec<usize>)[src]

Sets a new context

pub fn set_vec(&mut self, vector: Vec<T>)[src]

Set to a new vector. Clears the context.

pub fn clear(&mut self)[src]

Clears the vector and the context

pub fn push(&mut self, value: T)[src]

Push a value to the end of the vector

pub fn insert(&mut self, index: usize, value: T)[src]

Insert a value into the vector. Invalid context indices are updated.

pub fn pop(&mut self) -> Option<T>[src]

Pop a value from the end of the vector. If it succeeds invalid context indices are removed.

pub fn remove(&mut self, to_remove: usize) -> T[src]

Remove a value at the specified index. Deletes any context indices pointing to the removed value. Shifts all larger context indices down.

Trait Implementations

impl<T: Clone> Clone for ContextVec<T>[src]

impl<T: Default> Default for ContextVec<T>[src]

impl<T> Deref for ContextVec<T>[src]

type Target = [T]

The resulting type after dereferencing.

impl<T> DerefMut for ContextVec<T>[src]

impl<'de, T> Deserialize<'de> for ContextVec<T> where
    T: Deserialize<'de>, 
[src]

impl<T> Node for ContextVec<T> where
    T: Node + Serialize + DeserializeOwned + Default
[src]

impl<T> Serialize for ContextVec<T> where
    T: Serialize
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for ContextVec<T> where
    T: RefUnwindSafe

impl<T> Send for ContextVec<T> where
    T: Send

impl<T> Sync for ContextVec<T> where
    T: Sync

impl<T> Unpin for ContextVec<T> where
    T: Unpin

impl<T> UnwindSafe for ContextVec<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.