Struct maomi::prop::BindingValue

source ·
pub struct BindingValue<T> { /* private fields */ }
Expand description

A value that can be associated to a BindingProp .

Note that the BindingValue should be exclusively associated to one BindingProp . Panics if the value is associated to more than one BindingProp .

Implementations§

source§

impl<T> BindingValue<T>

source

pub fn new(default_value: T) -> Self

Create the property with initial value.

source

pub fn set(&mut self, v: T)

Set the value.

Updates of the value will NOT be applied to template! To change the value and apply in templates, create a new BindingValue instead.

source

pub fn with<R>(&self, f: impl FnOnce(&T) -> R) -> R

Get a reference of the value.

source

pub fn update<R>(&self, f: impl FnOnce(&mut T) -> R) -> R

Get a reference of the value.

Updates of the value will NOT be applied to template! To change the value and apply in templates, create a new BindingValue instead.

source§

impl<T: Clone> BindingValue<T>

source

pub fn get(&self) -> T

Get the cloned value.

Trait Implementations§

source§

impl<T: Debug> Debug for BindingValue<T>

source§

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

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

impl<T: Default> Default for BindingValue<T>

source§

fn default() -> BindingValue<T>

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

impl<T: Ord> Ord for BindingValue<T>

source§

fn cmp(&self, other: &BindingValue<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<T: PartialEq> PartialEq<BindingValue<T>> for BindingValue<T>

source§

fn eq(&self, other: &BindingValue<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd> PartialOrd<BindingValue<T>> for BindingValue<T>

source§

fn partial_cmp(&self, other: &BindingValue<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T> PropertyUpdate<BindingValue<T>> for BindingProp<T>

§

type UpdateContext = bool

Must be bool if used in components and updated through templates.
source§

fn compare_and_set_ref( dest: &mut Self, src: &BindingValue<T>, ctx: &mut Self::UpdateContext )

The updater. Read more
source§

impl<T: Eq> Eq for BindingValue<T>

source§

impl<T> StructuralEq for BindingValue<T>

source§

impl<T> StructuralPartialEq for BindingValue<T>

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for BindingValue<T>

§

impl<T> !Send for BindingValue<T>

§

impl<T> !Sync for BindingValue<T>

§

impl<T> Unpin for BindingValue<T>

§

impl<T> !UnwindSafe for BindingValue<T>

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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<S, T> ListPropertyItem<ListProp<T>, S> for Twhere S: PartialEq<S> + ?Sized, T: Default + PropAsRef<S>,

§

type Value = ()

The item value type. Read more
source§

fn item_value<'a>( dest: &mut ListProp<T>, index: usize, src: &'a S, ctx: &mut bool ) -> &'a <T as ListPropertyItem<ListProp<T>, S>>::Value

Get the item value. Read more
source§

impl<S, T> PropAsRef<S> for Twhere S: PartialEq<S> + ToOwned<Owned = T> + ?Sized, T: Borrow<S>,

source§

fn property_as_ref(&self) -> &S

Borrow &Self as &S .
source§

fn property_to_owned(s: &S) -> T

Clone &S as a new Self .
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.