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: impl IntoIterator<Item = T>) -> Self

Create a cursor from any iterable of themes. 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

pub fn set_index(&mut self, index: usize) -> Option<&T>

Moves the cursor to index and returns the theme at that position.

Returns None if index is out of bounds.

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.

Source

pub fn set_current(&mut self, name: &str) -> Option<&Theme>

Moves the cursor to the theme matching name (slug-insensitive) and returns it.

Accepts fuzzy names: “Nord Dark”, “nord-dark”, and “nordDark” all match the same theme. Returns None if no matching theme is found.

Trait Implementations§

Source§

impl<T: Clone> Clone for ThemeCursor<T>

Source§

fn clone(&self) -> ThemeCursor<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 ThemeCursor<T>

Source§

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

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

impl<T: PartialEq> PartialEq for ThemeCursor<T>

Source§

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

Source§

impl<T> StructuralPartialEq for ThemeCursor<T>

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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, 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.