pub trait Contextual {
type Ctx: RawContext;
// Required methods
fn ctx(&self) -> Self::Ctx;
fn ctx_mut(&mut self) -> &mut Self::Ctx;
// Provided methods
fn replace_ctx(&mut self, ctx: Self::Ctx) -> Self::Ctx { ... }
fn set_ctx(&mut self, ctx: Self::Ctx) -> &mut Self { ... }
fn swap_ctx(&mut self, other: &mut Self) { ... }
fn take_ctx(&mut self) -> Self::Ctx
where Self::Ctx: Default { ... }
}
Expand description
Contextual
is a trait for denoting types that are associated with a particular context.
Required Associated Types§
type Ctx: RawContext
Required Methods§
Provided Methods§
Sourcefn replace_ctx(&mut self, ctx: Self::Ctx) -> Self::Ctx
fn replace_ctx(&mut self, ctx: Self::Ctx) -> Self::Ctx
replace
with another and return the previous context
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.