[−][src]Struct tiny_ecs::MapRef
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
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]
U: From<T>,
impl<T> From<T> for T
[src]
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,