pub struct AccessCell<'a, 'b, T> { /* private fields */ }
Expand description
AccessCell
allows feather to track when a value passed into a function has actually been
changed, by tracking if a mutable borrow has been requested. Like std::cell::RefCell
, it
implements std::borrow::Borrow
and std::borrow::BorrowMut
, but also implements the
std::ops::Deref
and std::ops::DerefMut
operators so it can be used more like a smart
pointer.
Generally speaking, this type should never be constructed - it is used at Feather’s API boundaries where appropriate.
§Examples
use feather_ui::AccessCell;
struct FooBar {
i: i32,
}
fn change(change: bool, mut v: AccessCell<FooBar>) {
if change {
// FooBar only marked as changed once this mutable access happens
v.i = 4;
}
}
§Future-proofing
Currently, AccessCell
does not attempt to determine if the new value is actually different
than what was previously stored, because this would be a very expensive comparison. However,
in the future, a specialization of AccessCell for Persistent data structures that only marks
the value as changed if it is actually different when the AccessCell is dropped might be
implemented. As a result, you should assume that AccessCell implements Drop
even if it
technically doesn’t right now.
Trait Implementations§
Source§impl<'a, 'b, T> Borrow<T> for AccessCell<'a, 'b, T>
impl<'a, 'b, T> Borrow<T> for AccessCell<'a, 'b, T>
Source§impl<'a, 'b, T> BorrowMut<T> for AccessCell<'a, 'b, T>
impl<'a, 'b, T> BorrowMut<T> for AccessCell<'a, 'b, T>
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<'a, 'b, T> Deref for AccessCell<'a, 'b, T>
impl<'a, 'b, T> Deref for AccessCell<'a, 'b, T>
Auto Trait Implementations§
impl<'a, 'b, T> Freeze for AccessCell<'a, 'b, T>
impl<'a, 'b, T> RefUnwindSafe for AccessCell<'a, 'b, T>where
T: RefUnwindSafe,
impl<'a, 'b, T> Send for AccessCell<'a, 'b, T>where
T: Send,
impl<'a, 'b, T> Sync for AccessCell<'a, 'b, T>where
T: Sync,
impl<'a, 'b, T> Unpin for AccessCell<'a, 'b, T>
impl<'a, 'b, T> !UnwindSafe for AccessCell<'a, 'b, T>
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more