[][src]Struct tiny_ecs::MapRef

pub struct MapRef<'a, T> { /* fields omitted */ }

Immutable reference container for VecMap returned by Entities::borrow()

This struct is required to contain a hidden borrow to the requested VecMap. The reason for this is so we can borrow multiple VecMap, but not break the borrow checker rules for borrows on a single VecMap.

Methods from Deref<Target = VecMap<T>>

pub fn capacity(&self) -> usize[src]

Returns the number of elements the VecMap can hold without reallocating.

Examples

use vec_map::VecMap;
let map: VecMap<String> = VecMap::with_capacity(10);
assert!(map.capacity() >= 10);

pub fn keys(&self) -> Keys<V>[src]

Returns an iterator visiting all keys in ascending order of the keys. The iterator's element type is usize.

pub fn values(&self) -> Values<V>[src]

Returns an iterator visiting all values in ascending order of the keys. The iterator's element type is &'r V.

pub fn iter(&self) -> Iter<V>[src]

Returns an iterator visiting all key-value pairs in ascending order of the keys. The iterator's element type is (usize, &'r V).

Examples

use vec_map::VecMap;

let mut map = VecMap::new();
map.insert(1, "a");
map.insert(3, "c");
map.insert(2, "b");

// Print `1: a` then `2: b` then `3: c`
for (key, value) in map.iter() {
    println!("{}: {}", key, value);
}

pub fn len(&self) -> usize[src]

Returns the number of elements in the map.

Examples

use vec_map::VecMap;

let mut a = VecMap::new();
assert_eq!(a.len(), 0);
a.insert(1, "a");
assert_eq!(a.len(), 1);

pub fn is_empty(&self) -> bool[src]

Returns true if the map contains no elements.

Examples

use vec_map::VecMap;

let mut a = VecMap::new();
assert!(a.is_empty());
a.insert(1, "a");
assert!(!a.is_empty());

pub fn get(&self, key: usize) -> Option<&V>[src]

Returns a reference to the value corresponding to the key.

Examples

use vec_map::VecMap;

let mut map = VecMap::new();
map.insert(1, "a");
assert_eq!(map.get(1), Some(&"a"));
assert_eq!(map.get(2), None);

pub fn contains_key(&self, key: usize) -> bool[src]

Returns true if the map contains a value for the specified key.

Examples

use vec_map::VecMap;

let mut map = VecMap::new();
map.insert(1, "a");
assert_eq!(map.contains_key(1), true);
assert_eq!(map.contains_key(2), false);

Trait Implementations

impl<'a, T> Deref for MapRef<'a, T>[src]

type Target = VecMap<T>

The resulting type after dereferencing.

impl<'a, T: Debug> Debug for MapRef<'a, T>[src]

Auto Trait Implementations

impl<'a, T> !Send for MapRef<'a, T>

impl<'a, T> Unpin for MapRef<'a, T>

impl<'a, T> !Sync for MapRef<'a, T>

impl<'a, T> !UnwindSafe for MapRef<'a, T>

impl<'a, T> !RefUnwindSafe for MapRef<'a, T>

Blanket Implementations

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

impl<T> From<T> for 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]