Trait dyn_context::Stop
source · [−]pub trait Stop: Sized {
fn is_stopped(&self) -> bool;
fn stop(state: &mut dyn State);
fn drop(&mut self) { ... }
}Expand description
A destructor for State parts.
Implementing custom destructor for state parts and states may be tricky:
in a common case such action requires access to the &mut dyn State parameter
to do the work. Unfortunately, Rust does not support a
linear types concept, which would allow to have parameters in drop method.
This traits provides a way to specify custom destructor for State parts
as good as it is possible in Rust for now.
Use impl_stop_and_drop macro
to implement this trait in a right way.
This trait can be derived with custom proc macro Stop.
Required Methods
fn is_stopped(&self) -> bool
fn is_stopped(&self) -> bool
Checks if the type is ready to be dropped.
Provided Methods
Panics if the type is not ready to be dropped (and the current thread is not unwinding because of another panic).
This method is supposed to be called from Drop::drop.
Use impl_stop_and_drop macro
to get appropriate Drop implement by free.