Skip to main content

ThemeCursor

Struct ThemeCursor 

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

A cycling cursor over a list of themes of type T.

peek() returns the current theme without moving. next() and prev() advance or retreat the cursor and return the new current theme. Both wrap around at the ends.

To iterate over all themes without cycling, use ThemeCursor::themes.

§Type parameters

Implementations§

Source§

impl<T> ThemeCursor<T>

Source

pub fn new(themes: Vec<T>) -> Self

Create a cursor from an explicit list. The cursor starts at the first theme.

Source

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

Returns the current theme without moving the cursor.

Source

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

Advances the cursor to the next theme (wrapping) and returns it.

Returns None if the cursor is empty.

Source

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

Retreats the cursor to the previous theme (wrapping) and returns it.

Returns None if the cursor is empty.

Source

pub fn themes(&self) -> &[T]

Returns a slice of all themes in the cursor.

Source

pub fn len(&self) -> usize

Returns the number of themes.

Source

pub fn is_empty(&self) -> bool

Returns true if the cursor contains no themes.

Source§

impl ThemeCursor<Theme>

Convenience constructors for ThemeCursor<Theme>.

Source

pub fn with_builtins() -> Self

All built-in themes.

Source

pub fn with_user_themes() -> Self

User-installed themes only.

Source

pub fn with_all_themes() -> Self

Built-ins + user themes. User themes with matching names override builtins.

Auto Trait Implementations§

§

impl<T> Freeze for ThemeCursor<T>

§

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

§

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

§

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

§

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

§

impl<T> UnsafeUnpin for ThemeCursor<T>

§

impl<T> UnwindSafe for ThemeCursor<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, 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.