Skip to main content

WithSubState

Trait WithSubState 

Source
pub unsafe trait WithSubState<SubState> { }
Expand description

A state whose states map is the leading field (offset 0) and whose duel field follows at the same offset as SubState’s, so that &mut Self can be reinterpreted as &mut SubState.

§Safety

The implementor must guarantee that every field of SubState the handler will read through the reinterpreted view resides at the same offset in Self. For duel states this holds because the states map comes first in both (offset 0) and Self’s duel starts with SubState’s duel as a prefix.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> WithSubState<T> for T