[][src]Struct tiny_ecs::PartMap

pub struct PartMap<T> { /* fields omitted */ }

PartMap is a container type for the parts used by entities

Methods

impl<T> PartMap<T>[src]

pub fn get_part_ref(&self, id: u32) -> Result<&T, &'static str>[src]

pub fn get_part_mut(&mut self, id: u32) -> Result<&mut T, &'static str>[src]

Getting a reference to an entity part requires the entity ID and type signature. The type signature is required so that the internal downcast can be done for you.

Example

#[derive(Debug, PartialEq)]
struct Test1 {}

let partmap = entities.get_map_ref::<Test1>()
        .expect("No part found for entity");
let part = partmap.get_part_ref(entity_1).unwrap();
assert_eq!(part, &Test1 {});
// or
let part = partmap.get_part_ref(entity_1).unwrap();
assert_eq!(part, &Test1 {});

pub fn iter_ref(&self) -> Iter<u32, T>[src]

Returns an immutable iterator over the part map

Example


let partmap = entities.get_map_ref::<Test1>()
        .expect("No part found for entity");
for (k, v) in partmap.iter_ref() {
    assert!(v.x == *k);
}

pub fn iter_mut(&mut self) -> IterMut<u32, T>[src]

Returns a mutable iterator over the part map

Auto Trait Implementations

impl<T> Send for PartMap<T> where
    T: Send

impl<T> Sync for PartMap<T> where
    T: Sync

Blanket Implementations

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.

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

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

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