glib::collections::list

Struct List

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

A list of items of type T.

Behaves like an Iterator<Item = T> but allows modifications.

Implementations§

Source§

impl<T: TransparentPtrType> List<T>

Source

pub unsafe fn from_glib_none(list: *const GList) -> List<T>

Create a new List around a list.

Source

pub unsafe fn from_glib_container(list: *mut GList) -> List<T>

Create a new List around a list.

Source

pub unsafe fn from_glib_full(list: *mut GList) -> List<T>

Create a new List around a list.

Source

pub fn new() -> Self

Creates a new empty list.

Source

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

Create a non-destructive iterator over the List.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Create a non-destructive mutable iterator over the List.

Source

pub fn is_empty(&self) -> bool

Check if the list is empty.

This operation is O(1).

Source

pub fn len(&self) -> usize

Returns the length of the list.

This operation is O(n).

Source

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

Returns a reference to the first item of the list, if any.

This operation is O(1).

Source

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

Returns a mutable reference to the first item of the list, if any.

This operation is O(1).

Source

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

Removes the front item from the list, if any.

This operation is O(1).

Source

pub fn push_front(&mut self, item: T)

Prepends the new item to the front of the list.

This operation is O(1).

Source

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

Returns a reference to the last item of the list, if any.

This operation is O(n).

Source

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

Returns a mutable reference to the last item of the list, if any.

This operation is O(n).

Source

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

Removes the back item from the list, if any.

This operation is O(n).

Source

pub fn push_back(&mut self, item: T)

Appends the new item to the back of the list.

this operation is O(n).

Source

pub fn reverse(&mut self)

Reverse the list.

This operation is O(n).

Source

pub fn sort(&mut self)
where T: Ord,

Sorts the list.

This operation is O(n * log n).

Source

pub fn sort_by<F: FnMut(&T, &T) -> Ordering>(&mut self, f: F)

Sorts the list.

This operation is O(n * log n).

Source

pub fn clear(&mut self)

Removes all items from the list.

Source

pub fn retain(&mut self, f: impl FnMut(&T) -> bool)

Only keeps the item in the list for which f returns true.

Source

pub fn as_ptr(&self) -> *const GList

Returns the underlying pointer.

Source

pub fn as_mut_ptr(&mut self) -> *mut GList

Returns the underlying pointer.

Source

pub fn into_raw(self) -> *mut GList

Consumes the list and returns the underlying pointer.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Self

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: TransparentPtrType> Default for List<T>

Source§

fn default() -> Self

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

impl<T: TransparentPtrType> Drop for List<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: TransparentPtrType> 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: TransparentPtrType> FromGlibContainer<<T as GlibPtrDefault>::GlibType, *const GList> for List<T>

Source§

unsafe fn from_glib_none_num(ptr: *const GList, _num: usize) -> Self

Transfer: none. Read more
Source§

unsafe fn from_glib_container_num(_ptr: *const GList, _num: usize) -> Self

Transfer: container. Read more
Source§

unsafe fn from_glib_full_num(_ptr: *const GList, _num: usize) -> Self

Transfer: full. Read more
Source§

impl<T: TransparentPtrType> FromGlibContainer<<T as GlibPtrDefault>::GlibType, *mut GList> for List<T>

Source§

unsafe fn from_glib_none_num(ptr: *mut GList, _num: usize) -> Self

Transfer: none. Read more
Source§

unsafe fn from_glib_container_num(ptr: *mut GList, _num: usize) -> Self

Transfer: container. Read more
Source§

unsafe fn from_glib_full_num(ptr: *mut GList, _num: usize) -> Self

Transfer: full. Read more
Source§

impl<T: TransparentPtrType> FromGlibPtrContainer<<T as GlibPtrDefault>::GlibType, *const GList> for List<T>

Source§

unsafe fn from_glib_none(ptr: *const GList) -> Self

Transfer: none.
Source§

unsafe fn from_glib_container(_ptr: *const GList) -> Self

Transfer: container.
Source§

unsafe fn from_glib_full(_ptr: *const GList) -> Self

Transfer: full.
Source§

impl<T: TransparentPtrType> FromGlibPtrContainer<<T as GlibPtrDefault>::GlibType, *mut GList> for List<T>

Source§

unsafe fn from_glib_none(ptr: *mut GList) -> Self

Transfer: none.
Source§

unsafe fn from_glib_container(ptr: *mut GList) -> Self

Transfer: container.
Source§

unsafe fn from_glib_full(ptr: *mut GList) -> Self

Transfer: full.
Source§

impl<T: TransparentPtrType> 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: TransparentPtrType> IntoGlibPtr<*mut GList> for List<T>

Source§

unsafe fn into_glib_ptr(self) -> *mut GList

Transfer: full.
Source§

impl<'a, T: TransparentPtrType> IntoIterator for &'a List<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, 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<'a, T: TransparentPtrType> IntoIterator for &'a mut List<T>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, 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: TransparentPtrType> 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<'a, T: TransparentPtrType + 'a> ToGlibPtr<'a, *const GList> for List<T>

Source§

type Storage = PhantomData<&'a List<T>>

Source§

fn to_glib_none(&'a self) -> Stash<'a, *const GList, Self>

Transfer: none. Read more
Source§

fn to_glib_container(&'a self) -> Stash<'a, P, Self>

Transfer: container. Read more
Source§

fn to_glib_full(&self) -> P

Transfer: full. Read more
Source§

impl<'a, T: TransparentPtrType + 'a> ToGlibPtr<'a, *mut GList> for List<T>

Source§

type Storage = PhantomData<&'a List<T>>

Source§

fn to_glib_none(&'a self) -> Stash<'a, *mut GList, Self>

Transfer: none. Read more
Source§

fn to_glib_container(&'a self) -> Stash<'a, *mut GList, Self>

Transfer: container. Read more
Source§

fn to_glib_full(&self) -> *mut GList

Transfer: full. Read more
Source§

impl<'a, T: TransparentPtrType + 'a> ToGlibPtrMut<'a, *mut GList> for List<T>

Source§

type Storage = PhantomData<&'a mut List<T>>

Source§

fn to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut GList, Self>

Transfer: none. Read more
Source§

impl<T: Send + TransparentPtrType> Send for List<T>

Source§

impl<T: Sync + TransparentPtrType> Sync for List<T>

Auto Trait Implementations§

§

impl<T> Freeze for List<T>

§

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

§

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> TransparentType for T

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.