Struct Vector

Source
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>

Source

pub fn new() -> Self

Creates a new Vector.

Source

pub fn with_inner(inner_vec: Vec<T>) -> Self

Creates a new Vetocr with inner.

Source

pub fn init(&mut self, value: Option<Vec<T>>)

Initialize this. After initialization, this inner Option<Vec> becomes value.

Source

pub fn with_first_elem(elem: T) -> Self

Creates a new Vector with first element.

Source

pub fn push(&mut self, push: T)

Pushes push:T to this.

Source

pub fn has_at_least_one(&self) -> bool

Returns true if has some(n>0) items.

Source

pub fn len(&self) -> usize

Returns this Vector.

Source

pub fn append_vec(&mut self, other: Vec<T>)

Append other(Vec) to this inner.

Source

pub fn prepend_vec(&mut self, other: Vec<T>)

Prepend other(Vec) to this inner.

Source

pub fn insert(&mut self, index: usize, insert: T)

Insert T into this inner.

Source

pub fn append(&mut self, other: Vector<T>)

Appends other to this.

Source

pub fn is_none(&self) -> bool

Returns true if this inner is None.

Source

pub fn has_inner_vec(&self) -> bool

Returns true if this has inner vec(as Some(Vec)).

Source

pub fn set_none(&mut self)

Sets None as inner.

Source

pub fn clear(&mut self)

Clears inner vec. If inner is None, does nothing.

Source

pub fn inner(&self) -> &Option<Vec<T>>

Gets inner.

Source

pub fn inner_mut(&mut self) -> &mut Option<Vec<T>>

Gets inner as mutable form.

Source

pub fn take(&mut self) -> Vector<T>

Takes inner and returns Vector that stores the inner.

Source

pub fn take_inner(&mut self) -> Option<Vec<T>>

Takes inner

Source

pub fn inner_ref(self) -> Option<Vec<T>>

Gets inner reference.

Source

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

Returns a reference to an element has index(usize).

Source

pub fn remove(&mut self, index: usize) -> T

Removes and returns element at index. If index is out of bounds, will panic.

Source

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.

Source

pub fn remove_last(&mut self) -> T

Removes last element of inner vec. If inner vec is empty of None, will panic.

Source

pub fn is_empty(&self) -> bool

Returns true if inner is None or has no elements.

Source

pub fn first(&self) -> Option<&T>

Returns first element of self or None if self is empty.

Source

pub fn first_unwrap(&self) -> &T

Returns first element of self. If Self is Vector(NOne), error occured.

Source§

impl<T> Vector<Vector<T>>

Source

pub fn sum_of_length(&self) -> usize

Returns the sum of inner Vectors’ len.

Source

pub fn length_of_last(&self) -> usize

Returns the len fo last of inner Vectors.

Trait Implementations§

Source§

impl<T: Clone> Clone for Vector<T>

Source§

fn clone(&self) -> Vector<T>

Returns a copy 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<T: Debug> Debug for Vector<T>

Source§

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

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

impl<T> Default for Vector<T>

Default implementation of Vector Default of Vector is Vector(None)

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl FlagSearch for Vector<Flag>

Source§

fn find_long_flag(&self, name_or_alias: &str) -> LongFound<&Flag>

Finds long frag.
Source§

fn find_short_flag(&self, short_alias: &char) -> Option<&Flag>

Finds short flag.
Source§

fn find(&self, flag_name: &str) -> Option<&Flag>

Finds flag that has specidied name.
Source§

impl<T: FlagSearch> FlagSearch for Vector<T>

Source§

fn find_long_flag(&self, name_or_alias: &str) -> LongFound<&Flag>

Finds long frag.
Source§

fn find_short_flag(&self, name_or_alias: &char) -> Option<&Flag>

Finds short flag.
Source§

fn find(&self, name: &str) -> Option<&Flag>

Finds flag that has specidied name.
Source§

impl<T: Clone> From<&Vec<T>> for Vector<T>

Source§

fn from(vec: &Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Vector<String>

Source§

fn from(str: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Option<String>> for Vector<String>

Source§

fn from(t: Option<String>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Option<Vec<T>>> for Vector<T>

Source§

fn from(val: Option<Vec<T>>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Vector<String>

Source§

fn from(f: String) -> Vector<String>

Converts to this type from the input type.
Source§

impl<T> From<Vec<T>> for Vector<T>

Source§

fn from(vec: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<VecDeque<T>> for Vector<T>

Source§

fn from(vec_deque: VecDeque<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vector<T>> for Vec<T>

Source§

fn from(vec: Vector<T>) -> Vec<T>

Converts to this type from the input type.
Source§

impl<T> From<Vector<T>> for Vector<Vector<T>>

Source§

fn from(f: Vector<T>) -> Vector<Vector<T>>

Converts to this type from the input type.
Source§

impl<T: PartialEq> PartialEq for Vector<T>

Source§

fn eq(&self, other: &Vector<T>) -> 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<T: PartialOrd> PartialOrd for Vector<T>

Source§

fn partial_cmp(&self, other: &Vector<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> StructuralPartialEq for Vector<T>

Auto Trait Implementations§

§

impl<T> Freeze for Vector<T>

§

impl<T> RefUnwindSafe for Vector<T>
where T: RefUnwindSafe,

§

impl<T> Send for Vector<T>
where T: Send,

§

impl<T> Sync for Vector<T>
where T: Sync,

§

impl<T> Unpin for Vector<T>
where T: Unpin,

§

impl<T> UnwindSafe for Vector<T>
where T: 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<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<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.