Struct shipyard::AllStorages[][src]

pub struct AllStorages { /* fields omitted */ }
Expand description

Contains all components present in the World.

Implementations

Delete an entity and all its components. Returns true if entity was alive.

Example

let world = World::new();

let (mut entities, mut usizes, mut u32s) = world.borrow::<(EntitiesMut, &mut usize, &mut u32)>();

let entity1 = entities.add_entity((&mut usizes, &mut u32s), (0usize, 1u32));
let entity2 = entities.add_entity((&mut usizes, &mut u32s), (2usize, 3u32));

drop((entities, usizes, u32s));
world.run::<AllStorages, _, _>(|mut all_storages| {
    all_storages.delete(entity1);
});

world.run::<(&usize, &u32), _, _>(|(usizes, u32s)| {
    assert!((&usizes).get(entity1).is_err());
    assert!((&u32s).get(entity1).is_err());
    assert_eq!(usizes.get(entity2), Ok(&2));
    assert_eq!(u32s.get(entity2), Ok(&3));
});

Deletes all components from an entity without deleting it.

Deletes all entities and their components.

Borrows the requested storage, if it doesn’t exist it’ll get created.

You can use:

  • &T for a shared access to T storage
  • &mut T for an exclusive access to T storage
  • Entities for a shared access to the entity storage
  • EntitiesMut for an exclusive reference to the entity storage
  • AllStorages for an exclusive access to the storage of all components
  • Unique<&T> for a shared access to a T unique storage
  • Unique<&mut T> for an exclusive access to a T unique storage
  • ThreadPool for a shared access to the ThreadPool used by the World
  • NonSend: must activate the non_send feature
  • NonSync: must activate the non_sync feature
  • NonSendSync: must activate the non_send and non_sync features

Example

let world = World::new();
let all_storages = world.borrow::<AllStorages>();
let u32s = all_storages.try_borrow::<&u32>().unwrap();

Borrows the requested storage, if it doesn’t exist it’ll get created.
Unwraps errors.

You can use:

  • &T for a shared access to T storage
  • &mut T for an exclusive access to T storage
  • Entities for a shared access to the entity storage
  • EntitiesMut for an exclusive reference to the entity storage
  • AllStorages for an exclusive access to the storage of all components
  • Unique<&T> for a shared access to a T unique storage
  • Unique<&mut T> for an exclusive access to a T unique storage
  • ThreadPool for a shared access to the ThreadPool used by the World
  • NonSend: must activate the non_send feature
  • NonSync: must activate the non_sync feature
  • NonSendSync: must activate the non_send and non_sync features

Example

let world = World::new();
let all_storages = world.borrow::<AllStorages>();
let u32s = all_storages.borrow::<&u32>();

Trait Implementations

Returns the “default value” for a type. 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.

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.

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.

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 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.