Struct otter_api_tests::GPieces[][src]

pub struct GPieces(_);

Implementations

impl GPieces[src]

pub fn get_mut(&mut self, piece: PieceId) -> Option<&mut GPiece>[src]

pub fn values_mut(&mut self) -> ValuesMut<'_, PieceId, GPiece>

Notable traits for ValuesMut<'a, K, V>

impl<'a, K, V> Iterator for ValuesMut<'a, K, V> where
    K: 'a + Key
type Item = &'a mut V;
[src]

pub fn as_mut(&mut self, ModifyingPieces) -> &mut DenseSlotMap<PieceId, GPiece>[src]

Methods from Deref<Target = DenseSlotMap<PieceId, GPiece>>

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

Returns the number of elements in the slot map.

Examples

let mut sm = DenseSlotMap::with_capacity(10);
sm.insert("len() counts actual elements, not capacity");
let key = sm.insert("removed elements don't count either");
sm.remove(key);
assert_eq!(sm.len(), 1);

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

Returns if the slot map is empty.

Examples

let mut sm = DenseSlotMap::new();
let key = sm.insert("dummy");
assert_eq!(sm.is_empty(), false);
sm.remove(key);
assert_eq!(sm.is_empty(), true);

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

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

Examples

let sm: DenseSlotMap<_, f64> = DenseSlotMap::with_capacity(10);
assert_eq!(sm.capacity(), 10);

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

Returns true if the slot map contains key.

Examples

let mut sm = DenseSlotMap::new();
let key = sm.insert(42);
assert_eq!(sm.contains_key(key), true);
sm.remove(key);
assert_eq!(sm.contains_key(key), false);

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

Returns a reference to the value corresponding to the key.

Examples

let mut sm = DenseSlotMap::new();
let key = sm.insert("bar");
assert_eq!(sm.get(key), Some(&"bar"));
sm.remove(key);
assert_eq!(sm.get(key), None);

pub unsafe fn get_unchecked(&self, key: K) -> &V

Notable traits for &'_ mut R

impl<'_, R> Read for &'_ mut R where
    R: Read + ?Sized
impl<'_, W> Write for &'_ mut W where
    W: Write + ?Sized
impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
    F: Future + Unpin + ?Sized
type Output = <F as Future>::Output;
[src]

Returns a reference to the value corresponding to the key without version or bounds checking.

Safety

This should only be used if contains_key(key) is true. Otherwise it is potentially unsafe.

Examples

let mut sm = DenseSlotMap::new();
let key = sm.insert("bar");
assert_eq!(unsafe { sm.get_unchecked(key) }, &"bar");
sm.remove(key);
// sm.get_unchecked(key) is now dangerous!

pub fn iter(&self) -> Iter<'_, K, V>

Notable traits for Iter<'a, K, V>

impl<'a, K, V> Iterator for Iter<'a, K, V> where
    K: 'a + Key
type Item = (K, &'a V);
[src]

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (K, &'a V).

Examples

let mut sm = DenseSlotMap::new();
let k0 = sm.insert(0);
let k1 = sm.insert(1);
let k2 = sm.insert(2);

let mut it = sm.iter();
for (k, v) in sm.iter() {
    println!("key: {:?}, val: {}", k, v);
}

pub fn keys(&self) -> Keys<'_, K, V>

Notable traits for Keys<'a, K, V>

impl<'a, K, V> Iterator for Keys<'a, K, V> where
    K: 'a + Key
type Item = K;
[src]

An iterator visiting all keys in arbitrary order. The iterator element type is K.

Examples

let mut sm = DenseSlotMap::new();
let k0 = sm.insert(10);
let k1 = sm.insert(20);
let k2 = sm.insert(30);
let keys: HashSet<_> = sm.keys().collect();
let check: HashSet<_> = vec![k0, k1, k2].into_iter().collect();
assert_eq!(keys, check);

pub fn values(&self) -> Values<'_, K, V>

Notable traits for Values<'a, K, V>

impl<'a, K, V> Iterator for Values<'a, K, V> where
    K: 'a + Key
type Item = &'a V;
[src]

An iterator visiting all values in arbitrary order. The iterator element type is &'a V.

Examples

let mut sm = DenseSlotMap::new();
let k0 = sm.insert(10);
let k1 = sm.insert(20);
let k2 = sm.insert(30);
let values: HashSet<_> = sm.values().collect();
let check: HashSet<_> = vec![&10, &20, &30].into_iter().collect();
assert_eq!(values, check);

Trait Implementations

impl ById for GPieces[src]

type Id = PieceId

type Entry = GPiece

type Error = PieceOpError

impl Debug for GPieces[src]

impl Default for GPieces[src]

impl Deref for GPieces[src]

type Target = DenseSlotMap<PieceId, GPiece>

The resulting type after dereferencing.

impl<'de> Deserialize<'de> for GPieces[src]

impl<'p> IntoIterator for &'p mut GPieces[src]

type Item = (PieceId, &'p mut GPiece)

The type of the elements being iterated over.

type IntoIter = IterMut<'p, PieceId, GPiece>

Which kind of iterator are we turning this into?

impl Serialize for GPieces[src]

Auto Trait Implementations

impl !RefUnwindSafe for GPieces

impl Send for GPieces

impl !Sync for GPieces

impl Unpin for GPieces

impl !UnwindSafe for GPieces

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> Downcast for T where
    T: Any

impl<A> DynCastExt for A

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

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

impl<T> Serialize for T where
    T: Serialize + ?Sized
[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<V, T> VZip<V> for T where
    V: MultiLane<T>,