Trait Builder

Source
pub trait Builder {
    // Required methods
    fn with<C: Component + Send + Sync>(self, c: C) -> Self;
    fn build(self) -> Entity;

    // Provided method
    fn maybe_with<C: Component + Send + Sync>(self, c: Option<C>) -> Self
       where Self: Sized { ... }
}
Expand description

A common trait for EntityBuilder and LazyBuilder, allowing either to be used. Entity is definitely alive, but the components may or may not exist before a call to World::maintain.

Required Methods§

Source

fn with<C: Component + Send + Sync>(self, c: C) -> Self

Appends a component and associates it with the entity.

If a component was already associated with the entity, it should overwrite the previous component.

§Panics

Panics if the component hasn’t been register()ed in the World.

Source

fn build(self) -> Entity

Finishes the building and returns the entity.

Provided Methods§

Source

fn maybe_with<C: Component + Send + Sync>(self, c: Option<C>) -> Self
where Self: Sized,

Convenience method that calls self.with(component) if Some(component) is provided

§Panics

Panics if the component hasn’t been register()ed in the World.

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.

Implementors§

Source§

impl<'a> Builder for EntityBuilder<'a>

Source§

impl<'a> Builder for LazyBuilder<'a>