[][src]Struct world_dispatcher::World

pub struct World { /* fields omitted */ }

Contains data indexed by type. World allows to dynamically enforce the rust rules of borrowing and ownership at runtime:

  • The same type cannot be borrowed immutably and mutably at the same time.
  • The same type cannot be borrowed mutably more than once at the same time.

Implementations

impl World[src]

pub fn initialize<T: Default + 'static>(&mut self)[src]

Initializes a resource to its default value. This is the only way to "insert" a resource.

It is suggested to use a macro to collect all the resources and initialize all of them.

pub fn get<T: 'static>(&self) -> Result<Ref<'_, T>, EcsError>[src]

Get an immutable reference to a resource by type. Will return an error if the type is:

  • Non initialized
  • Already borrowed mutably

pub fn get_mut<T: 'static>(&self) -> Result<RefMut<'_, T>, EcsError>[src]

Get a mutable reference to a resource by type. Will return an error if the type is:

  • Non initialized
  • Already borrowed immutably
  • Already borrowed mutably

Trait Implementations

impl Default for World[src]

impl Sync for World[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.