#[non_exhaustive]pub enum AppearanceWrite<T> {
Refused,
Accepted {
was: Option<T>,
},
}Expand description
What a SceneItem appearance setter did — and, when it did anything,
the value it overwrote.
§Why the old value comes out of the setter
ItemChange::AppearanceChanged carries an old, so a
data layer can reverse a colour edit. That old has to come from
somewhere, and the item is the only thing that has it: a fill lives inside
the item, not on the scene entry.
The obvious shape — a fn fill(&self) -> Option<ColorProp> getter beside
the setter — cannot be required, because most items have no fill slot at
all, so it would have to be defaulted. A defaulted getter returning
None would then report “there was no fill” for every third-party item
that implements set_fill and forgets the getter, and an undone fill
change would clear the fill instead of restoring it. Silent-wrong is the
worst failure a journal can have.
Returning the old value from the setter has no default to get wrong: the
code that overwrites the slot is the code that hands back what it
overwrote, and the compiler will not let an implementor write one without
the other. The default impl is Refused, which is exactly
true of an item with no such slot and emits no change at all.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Refused
This item kind has no such slot, or rejected this particular value
(TextItem always has a foreground colour, so it
refuses a None fill). Nothing was written, and the scene emits no
change.
Accepted
The slot took the value. was is what it held immediately before —
None when the slot was empty.
Implementations§
Source§impl<T> AppearanceWrite<T>
impl<T> AppearanceWrite<T>
Sourcepub fn into_previous(self) -> Option<Option<T>>
pub fn into_previous(self) -> Option<Option<T>>
The overwritten slot contents, or None when the write was refused.
The outer Option is “did anything happen”; the inner one is “was the
slot occupied”.
Trait Implementations§
Source§impl<T: Clone> Clone for AppearanceWrite<T>
impl<T: Clone> Clone for AppearanceWrite<T>
Source§fn clone(&self) -> AppearanceWrite<T>
fn clone(&self) -> AppearanceWrite<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<T> Freeze for AppearanceWrite<T>where
T: Freeze,
impl<T> RefUnwindSafe for AppearanceWrite<T>where
T: RefUnwindSafe,
impl<T> Send for AppearanceWrite<T>where
T: Send,
impl<T> Sync for AppearanceWrite<T>where
T: Sync,
impl<T> Unpin for AppearanceWrite<T>where
T: Unpin,
impl<T> UnsafeUnpin for AppearanceWrite<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for AppearanceWrite<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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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