Struct glib::collections::slist::SList

source ·
#[repr(transparent)]
pub struct SList<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> SList<T>

source

pub unsafe fn from_glib_none(list: *const GSList) -> SList<T>

Create a new SList around a list.

source

pub unsafe fn from_glib_container(list: *mut GSList) -> SList<T>

Create a new SList around a list.

source

pub unsafe fn from_glib_full(list: *mut GSList) -> SList<T>

Create a new SList 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 SList.

source

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

Create a non-destructive mutable iterator over the SList.

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 GSList

Returns the underlying pointer.

source

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

Returns the underlying pointer.

source

pub fn into_raw(self) -> *mut GSList

Consumes the list and returns the underlying pointer.

Trait Implementations§

source§

impl<T: TransparentPtrType> Clone for SList<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 SList<T>

source§

fn default() -> Self

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

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

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T: TransparentPtrType> FromGlibContainer<<T as GlibPtrDefault>::GlibType, *const GSList> for SList<T>

source§

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

Transfer: none. Read more
source§

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

Transfer: container. Read more
source§

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

Transfer: full. Read more
source§

impl<T: TransparentPtrType> FromGlibContainer<<T as GlibPtrDefault>::GlibType, *mut GSList> for SList<T>

source§

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

Transfer: none. Read more
source§

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

Transfer: container. Read more
source§

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

Transfer: full. Read more
source§

impl<T: TransparentPtrType> FromGlibPtrContainer<<T as GlibPtrDefault>::GlibType, *const GSList> for SList<T>

source§

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

Transfer: none.
source§

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

Transfer: container.
source§

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

Transfer: full.
source§

impl<T: TransparentPtrType> FromGlibPtrContainer<<T as GlibPtrDefault>::GlibType, *mut GSList> for SList<T>

source§

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

Transfer: none.
source§

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

Transfer: container.
source§

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

Transfer: full.
source§

impl<T: TransparentPtrType> FromIterator<T> for SList<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 GSList> for SList<T>

source§

unsafe fn into_glib_ptr(self) -> *mut GSList

Transfer: full.
source§

impl<'a, T: TransparentPtrType> IntoIterator for &'a SList<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 SList<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 SList<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 GSList> for SList<T>

§

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

source§

fn to_glib_none(&'a self) -> Stash<'a, *const GSList, 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 GSList> for SList<T>

§

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

source§

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

Transfer: none. Read more
source§

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

Transfer: container. Read more
source§

fn to_glib_full(&self) -> *mut GSList

Transfer: full. Read more
source§

impl<'a, T: TransparentPtrType + 'a> ToGlibPtrMut<'a, *mut GSList> for SList<T>

§

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

source§

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

Transfer: none. Read more
source§

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

source§

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

Auto Trait Implementations§

§

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

§

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

§

impl<T> UnwindSafe for SList<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere T: TransparentPtrType,

source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.