Enum finestra::StateOrRaw
source · pub enum StateOrRaw<T> {
Raw(T),
State(State<T>),
}
Expand description
Variants§
Raw(T)
A raw value is a value that is applied once, but can’t be updated using the State pattern.
State(State<T>)
This value is reacted by Finestra, and potentially you, by updating the used value (such as the text of a Label).
Implementations§
source§impl<T> StateOrRaw<T>
impl<T> StateOrRaw<T>
sourcepub fn with<F: FnOnce(&T) -> R, R>(&self, f: F) -> R
pub fn with<F: FnOnce(&T) -> R, R>(&self, f: F) -> R
Get the value within, by using a visitor method.
let state = StateOrRaw::Raw("Hello, world!".to_string());
state.with(|value| {
println!("Value is: {value}");
});
sourcepub fn clone_inner(&self) -> Twhere
T: Clone,
pub fn clone_inner(&self) -> Twhere
T: Clone,
Clone the inner value. Note: you can also use StateOrRaw::with()
if
you only need a temporary reference.
let value = StateOrRaw::Raw("Hello, world!".to_string());
let cloned: String = value.clone_inner();
Trait Implementations§
source§impl<T: Debug> Debug for StateOrRaw<T>
impl<T: Debug> Debug for StateOrRaw<T>
source§impl<T> Default for StateOrRaw<T>where
T: Default,
impl<T> Default for StateOrRaw<T>where
T: Default,
source§impl<T> From<&State<T>> for StateOrRaw<T>
impl<T> From<&State<T>> for StateOrRaw<T>
source§impl<T> From<State<T>> for StateOrRaw<T>
impl<T> From<State<T>> for StateOrRaw<T>
source§impl From<SystemColor> for StateOrRaw<Color>
impl From<SystemColor> for StateOrRaw<Color>
source§fn from(value: SystemColor) -> Self
fn from(value: SystemColor) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<T> RefUnwindSafe for StateOrRaw<T>where
T: RefUnwindSafe,
impl<T> Send for StateOrRaw<T>where
T: Send,
impl<T> Sync for StateOrRaw<T>where
T: Sync,
impl<T> Unpin for StateOrRaw<T>where
T: Unpin,
impl<T> UnwindSafe for StateOrRaw<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more