Skip to main content

Property

Struct Property 

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

Stores an explicit value or a lazily computed binding result.

The default closure supplied to get describes the same binding on each read.

Implementations§

Source§

impl<T> Property<T>

Source

pub fn new(binding: Option<Box<dyn Fn() -> T>>) -> Self

Source

pub fn set(&self, value: T)

Source

pub fn is_dirty(&self) -> bool

Inspect whether a cached binding needs reevaluation without tracking a read.

Source

pub fn reset(&self)

Source§

impl<T: PartialEq> Property<T>

Source

pub fn set_if_changed(&self, value: T)

Override the binding and invalidate dependents only when its known value changes.

Source§

impl<T: Clone> Property<T>

Source

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

Observe an explicit override while leaving the default to the caller.

Source

pub fn get(&self, default: impl FnOnce() -> T) -> T

Trait Implementations§

Source§

impl<T> Default for Property<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> !Freeze for Property<T>

§

impl<T> !RefUnwindSafe for Property<T>

§

impl<T> !Send for Property<T>

§

impl<T> !Sync for Property<T>

§

impl<T> !UnwindSafe for Property<T>

§

impl<T> Forget for Property<T>

§

impl<T> Unpin for Property<T>
where RefCell<Stored<T>>: Unpin, Option<Box<dyn Fn() -> T>>: Unpin,

§

impl<T> UnsafeUnpin for Property<T>
where RefCell<Stored<T>>: UnsafeUnpin, Option<Box<dyn Fn() -> T>>: UnsafeUnpin,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.