Skip to main content

SceneListBox

Trait SceneListBox 

Source
pub trait SceneListBox:
    Send
    + Sync
    + 'static {
    // Required methods
    fn resolve_list_box(
        self: Box<Self>,
        context: &mut ResolveContext<'_>,
        scenes: &mut Vec<ResolvedScene>,
    ) -> Result<(), ResolveSceneError>;
    fn register_dependencies_box(&self, dependencies: &mut SceneDependencies);
}
Expand description

Boxed version of SceneList, which enables implementing SceneList for Box<dyn SceneList>. Most developers do not need to think about or use this trait.

Related: SceneBox.

§Why does this exist?

SceneList::resolve_list consumes self, which by default is not something that Box<dyn SceneList> can do in Rust, as dyn Scene is “unsized”. The “way out” is to have every Scene type also know how to resolve itself for self: Box<Self>. SceneListBox has a blanket impl for SceneList + Sized (which can just rely on the SceneList impl). Then Box<dyn SceneList> has a manual SceneListBox impl that relies on the stored SceneListBox::resolve_list_box impl.

Required Methods§

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<L> SceneListBox for L
where L: SceneList,