Struct List

Source
pub struct List<T> { /* private fields */ }
Expand description

List is collection of homogeneous objects.

Implementations§

Source§

impl<T> List<T>

Source

pub fn new() -> Self

Construct an empty list.

Source

pub fn len(&self) -> i32

Return the number of elements in the list.

Source

pub fn is_empty(&self) -> bool

Return true if the list contains no elements.

Source

pub fn iter(&self) -> Iter<'_, T>

Return an iterator over the list.

Source

pub fn find(&self, element: &T) -> Option<&T>
where T: PartialEq,

Return the first occurrence of the specified element or None in the list.

Source

pub fn contains(&self, element: &T) -> bool
where T: PartialEq,

Return true if the list contains element.

Source

pub fn count(&self, element: &T) -> usize
where T: PartialEq,

Count the number of occurrence of the specified element.

Source

pub fn uniquify(&self) -> Self
where T: PartialEq + Clone,

Return a list that eliminates duplicate elements and keep the original relative order of elements.

Source

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

Insert the specified element at the specified index in the list. Index can be negative.

Source

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

Remove and return the element at the specified index in the list. Index can be negative.

Source

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

Append an element to the back of the list.

Source

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

Remove the last element from a list and return it, or None if it is empty.

Source

pub fn clear(&mut self)

Clear the list.

Source

pub fn reverse(&mut self)

Reverse the order of elements in the list, in place.

Trait Implementations§

Source§

impl<T> Add<&List<T>> for &List<T>
where List<T>: Clone,

Source§

type Output = List<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &List<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<&List<T>> for List<T>
where List<T>: Clone,

Source§

type Output = List<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &List<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<List<T>> for &List<T>
where List<T>: Clone,

Source§

type Output = List<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: List<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add for List<T>

Source§

type Output = List<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: List<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> AddAssign<&List<T>> for List<T>
where List<T>: Clone,

Source§

fn add_assign(&mut self, rhs: &List<T>)

Performs the += operation. Read more
Source§

impl<T> AddAssign for List<T>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for List<T>

Source§

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

Returns a duplicate 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 List<T>

Source§

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

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

impl<T: Default> Default for List<T>

Source§

fn default() -> List<T>

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

impl<T: Display> Display for List<T>

Source§

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

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

impl<T> Extend<T> for List<T>

Source§

fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T, const N: usize> From<[T; N]> for List<T>

Source§

fn from(value: [T; N]) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vec<T>> for List<T>

Source§

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

Converts to this type from the input type.
Source§

impl<T> FromIterator<T> for List<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Hash> Hash for List<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> Index<i32> for List<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: i32) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<i32> for List<T>

Source§

fn index_mut(&mut self, index: i32) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> IntoIterator for List<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: Ord> Ord for List<T>

Source§

fn cmp(&self, other: &List<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq> PartialEq for List<T>

Source§

fn eq(&self, other: &List<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 List<T>

Source§

fn partial_cmp(&self, other: &List<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: Eq> Eq for List<T>

Source§

impl<T> StructuralPartialEq for List<T>

Auto Trait Implementations§

§

impl<T> Freeze for List<T>

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for List<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V