Struct glib::collections::list::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> 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>

§

type Item = &'a T

The type of the elements being iterated over.
§

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>

§

type Item = &'a mut T

The type of the elements being iterated over.
§

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>

§

type Item = T

The type of the elements being iterated over.
§

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>

§

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>

§

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>

§

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

§

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

§

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

§

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.