[−][src]Struct tiny_ecs::PartMap
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
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,