pub struct Vector<T>(pub Option<Vec<T>>);Expand description
struct Vector is a new type pattern of Option<Vec
Tuple Fields§
§0: Option<Vec<T>>Implementations§
Source§impl<T> Vector<T>
impl<T> Vector<T>
Sourcepub fn with_inner(inner_vec: Vec<T>) -> Self
pub fn with_inner(inner_vec: Vec<T>) -> Self
Creates a new Vetocr with inner.
Sourcepub fn init(&mut self, value: Option<Vec<T>>)
pub fn init(&mut self, value: Option<Vec<T>>)
Initialize this. After initialization, this inner Option<Vec
Sourcepub fn with_first_elem(elem: T) -> Self
pub fn with_first_elem(elem: T) -> Self
Creates a new Vector with first element.
Sourcepub fn has_at_least_one(&self) -> bool
pub fn has_at_least_one(&self) -> bool
Returns true if has some(n>0) items.
Sourcepub fn append_vec(&mut self, other: Vec<T>)
pub fn append_vec(&mut self, other: Vec<T>)
Append other(Vec
Sourcepub fn prepend_vec(&mut self, other: Vec<T>)
pub fn prepend_vec(&mut self, other: Vec<T>)
Prepend other(Vec
Sourcepub fn has_inner_vec(&self) -> bool
pub fn has_inner_vec(&self) -> bool
Returns true if this has inner vec(as Some(Vec
Sourcepub fn take_inner(&mut self) -> Option<Vec<T>>
pub fn take_inner(&mut self) -> Option<Vec<T>>
Takes inner
Sourcepub fn get(&self, index: usize) -> Option<&T>
pub fn get(&self, index: usize) -> Option<&T>
Returns a reference to an element has index(usize).
Sourcepub fn remove(&mut self, index: usize) -> T
pub fn remove(&mut self, index: usize) -> T
Removes and returns element at index. If index is out of bounds, will panic.
Sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes last element of inner vec and returns it. If inner vec is empty or None, returns None.
Sourcepub fn remove_last(&mut self) -> T
pub fn remove_last(&mut self) -> T
Removes last element of inner vec. If inner vec is empty of None, will panic.
Sourcepub fn first_unwrap(&self) -> &T
pub fn first_unwrap(&self) -> &T
Returns first element of self. If Self is Vector(NOne), error occured.
Source§impl<T> Vector<Vector<T>>
impl<T> Vector<Vector<T>>
Sourcepub fn sum_of_length(&self) -> usize
pub fn sum_of_length(&self) -> usize
Returns the sum of inner Vectors’ len.
Sourcepub fn length_of_last(&self) -> usize
pub fn length_of_last(&self) -> usize
Returns the len fo last of inner Vectors.
Trait Implementations§
Source§impl<T> Default for Vector<T>
Default implementation of Vector
Default of Vector is Vector(None)
impl<T> Default for Vector<T>
Default implementation of Vector Default of Vector is Vector(None)