pub struct DeferredTreeBuilder<T> { /* fields omitted */ }
Expand description

Ergonomically construct trees without knowledge of world.

This struct builds the world using EntityBuilderClone

Example

use hecs_hierarchy::*;
use hecs::*;

struct Tree;
let mut world = World::default();
let mut builder = DeferredTreeBuilder::<Tree>::from_bundle(("root",));
builder.attach_bundle(("child 1",));
builder.attach({
    let mut builder = DeferredTreeBuilder::new();
    builder.add("child 2");
    builder
});
let root = builder.build(&mut world);
assert_eq!(*world.get::<&'static str>(root).unwrap(), "root");
for (a, b) in world
    .descendants_depth_first::<Tree>(root)
    .zip(["child 1", "child 2"])
{
    assert_eq!(*world.get::<&str>(a).unwrap(), b)
}

Implementations

Add a component to the root

Add a bundle to the root

Atttach a new subtree

Attach a new leaf as an entity builder

Attach a new leaf as a bundle

Get a reference to the deferred tree builder’s builder.

Get a reference to the deferred tree builder’s children.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.