Skip to main content

OptionObserver

Struct OptionObserver 

Source
pub struct OptionObserver<'ob, O, S: ?Sized, D = Zero> { /* private fields */ }
Expand description

Observer implementation for Option<T>.

This observer tracks changes to optional values, including transitions between Some and None states. It provides specialized methods for working with options while maintaining change tracking.

Implementations§

Source§

impl<'ob, O, S, D> OptionObserver<'ob, O, S, D>
where D: Unsigned, S: AsDerefMut<D, Target = Option<O::Head>> + 'ob + ?Sized, O: Observer<'ob, InnerDepth = Zero>, O::Head: Sized,

Source

pub fn as_mut(&mut self) -> Option<&mut O>

Source

pub fn insert(&mut self, value: O::Head) -> &mut O

Source

pub fn get_or_insert(&mut self, value: O::Head) -> &mut O

Source

pub fn get_or_insert_default(&mut self) -> &mut O
where O::Head: Default,

Source

pub fn get_or_insert_with<F>(&mut self, f: F) -> &mut O
where F: FnOnce() -> O::Head,

Trait Implementations§

Source§

impl<'ob, O, S: ?Sized, D> AsNormalized for OptionObserver<'ob, O, S, D>

Source§

type OuterDepth = Succ<Zero>

The number of outer dereference layers to reach the normalized value.
Source§

fn as_normalized_ref(&self) -> &Self::Target

Returns a normalized reference to the underlying value.
Source§

fn as_normalized_mut(&mut self) -> &mut Self::Target
where Self: AsDerefMutCoinductive<Self::OuterDepth>,

Returns a normalized mutable reference to the underlying value.
Source§

impl<'ob, O, S, D> Debug for OptionObserver<'ob, O, S, D>
where D: Unsigned, S: AsDerefMut<D, Target: Debug> + ?Sized,

Source§

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

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

impl<'ob, O, S: ?Sized, D> Deref for OptionObserver<'ob, O, S, D>

Source§

type Target = Pointer<S>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'ob, O, S: ?Sized, D> DerefMut for OptionObserver<'ob, O, S, D>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'ob, O, S, D> Observer<'ob> for OptionObserver<'ob, O, S, D>
where D: Unsigned, S: AsDerefMut<D, Target = Option<O::Head>> + 'ob + ?Sized, O: Observer<'ob, InnerDepth = Zero>, O::Head: Sized,

Source§

type InnerDepth = D

Type-level number of dereferences from Head to the observed type.
Source§

type Head = S

The head type of the dereference chain.
Source§

fn uninit() -> Self

Creates an uninitialized observer. Read more
Source§

unsafe fn refresh(this: &mut Self, value: &mut Self::Head)

Refreshes the observer’s internal pointer after the observed value has moved. Read more
Source§

fn observe(value: &'ob mut Self::Head) -> Self

Creates a new observer for the given value. Read more
Source§

unsafe fn force(this: &mut Self, value: &'ob mut Self::Head)

Forces the observer into a valid state for the given value. Read more
Source§

fn as_inner<'i>( this: &Self, ) -> &'i mut <Self::Head as AsDeref<Self::InnerDepth>>::Target
where Self::Head: AsDerefMut<Self::InnerDepth>, 'ob: 'i,

Gets a mutable reference to the inner observed value without triggering observation. Read more
Source§

fn track_inner<'i>( this: &mut Self, ) -> &'i mut <Self::Head as AsDeref<Self::InnerDepth>>::Target
where Self::Head: AsDerefMut<Self::InnerDepth>, 'ob: 'i,

Gets a mutable reference to the inner observed value while triggering observation. Read more
Source§

impl<'ob, O, S, D, U: ?Sized> PartialEq<U> for OptionObserver<'ob, O, S, D>
where D: Unsigned, S: AsDerefMut<D, Target: PartialEq<U>> + ?Sized,

Source§

fn eq(&self, other: &U) -> 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<'ob, O, S, D, U: ?Sized> PartialOrd<U> for OptionObserver<'ob, O, S, D>
where D: Unsigned, S: AsDerefMut<D, Target: PartialOrd<U>> + ?Sized,

Source§

fn partial_cmp(&self, other: &U) -> 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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'ob, O, S, D> SerializeObserver<'ob> for OptionObserver<'ob, O, S, D>
where D: Unsigned, S: AsDerefMut<D, Target = Option<O::Head>> + 'ob + ?Sized, O: SerializeObserver<'ob, InnerDepth = Zero>, O::Head: Serialize + Sized,

Source§

unsafe fn flush_unchecked<A: Adapter>( this: &mut Self, ) -> Result<Mutations<A::Value>, A::Error>

Flushes and serializes all recorded mutations (unsafe version). Read more
Source§

fn flush<A: Adapter>(this: &mut Self) -> Result<Mutations<A::Value>, A::Error>

Flushes and serializes all recorded mutations using the specified adapter. Read more

Auto Trait Implementations§

§

impl<'ob, O, S, D = Zero> !Freeze for OptionObserver<'ob, O, S, D>

§

impl<'ob, O, S, D = Zero> !RefUnwindSafe for OptionObserver<'ob, O, S, D>

§

impl<'ob, O, S, D = Zero> !Send for OptionObserver<'ob, O, S, D>

§

impl<'ob, O, S, D = Zero> !Sync for OptionObserver<'ob, O, S, D>

§

impl<'ob, O, S, D> Unpin for OptionObserver<'ob, O, S, D>
where O: Unpin, S: ?Sized,

§

impl<'ob, O, S, D = Zero> !UnwindSafe for OptionObserver<'ob, O, S, D>

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> AsDeref<Zero> for T
where T: ?Sized,

Source§

type Target = T

The target type after N dereferences.
Source§

fn as_deref(&self) -> &T

Dereferences self N times.
Source§

impl<T, N> AsDerefCoinductive<Succ<N>> for T
where T: Deref + ?Sized, <T as Deref>::Target: AsDerefCoinductive<N>, N: Unsigned,

Source§

type Target = <<T as Deref>::Target as AsDerefCoinductive<N>>::Target

The target type after N dereferences.
Source§

fn as_deref_coinductive(&self) -> &<T as AsDerefCoinductive<Succ<N>>>::Target

Dereferences self N times.
Source§

impl<T> AsDerefCoinductive<Zero> for T
where T: ?Sized,

Source§

type Target = T

The target type after N dereferences.
Source§

fn as_deref_coinductive(&self) -> &T

Dereferences self N times.
Source§

impl<T> AsDerefMut<Zero> for T
where T: ?Sized,

Source§

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

Mutably dereferences self N times.
Source§

impl<T, N> AsDerefMutCoinductive<Succ<N>> for T

Source§

fn as_deref_mut_coinductive( &mut self, ) -> &mut <T as AsDerefCoinductive<Succ<N>>>::Target

Mutably dereferences self N times.
Source§

impl<T> AsDerefMutCoinductive<Zero> for T
where T: ?Sized,

Source§

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

Mutably dereferences self N times.
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<'ob, T> SerializeObserverExt<'ob> for T
where T: SerializeObserver<'ob>,

Source§

fn flush<A: Adapter>(&mut self) -> Result<A, A::Error>

Collects mutations using the specified adapter. 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.