[−][src]Struct treeflection::context_vec::ContextVec
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]
fn clone(&self) -> ContextVec<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Default> Default for ContextVec<T>
[src]
fn default() -> ContextVec<T>
[src]
impl<T> Deref for ContextVec<T>
[src]
impl<T> DerefMut for ContextVec<T>
[src]
impl<'de, T> Deserialize<'de> for ContextVec<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl<T> Node for ContextVec<T> where
T: Node + Serialize + DeserializeOwned + Default,
[src]
T: Node + Serialize + DeserializeOwned + Default,
fn node_step(&mut self, runner: NodeRunner) -> String
[src]
impl<T> Serialize for ContextVec<T> where
T: Serialize,
[src]
T: Serialize,
Auto Trait Implementations
impl<T> RefUnwindSafe for ContextVec<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for ContextVec<T> where
T: Send,
T: Send,
impl<T> Sync for ContextVec<T> where
T: Sync,
T: Sync,
impl<T> Unpin for ContextVec<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for ContextVec<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,