[−][src]Struct key_vec::KeyVec
Vec of key-value pairs sorted by key.
See crate-level documentation for examples.
Implementations
impl<K, V> KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
pub fn new() -> Self[src]
pub fn with_capacity(capacity: usize) -> Self[src]
pub fn insert(&mut self, key: K, value: V) -> Option<V>[src]
Insert an (key,value) pair, returning an existing value if one was present for the corresponding key.
pub fn get(&self, key: &K) -> Option<&V>[src]
pub fn get_mut(&mut self, key: &K) -> Option<&mut V>[src]
pub fn remove(&mut self, key: &K) -> Option<V>[src]
pub fn remove_index(&mut self, index: usize) -> (K, V)[src]
Panics if index is out of bounds
pub fn pop(&mut self) -> Option<(K, V)>[src]
pub fn clear(&mut self)[src]
pub fn drain<R>(&mut self, range: R) -> Drain<'_, (K, V)> where
R: RangeBounds<usize>, [src]
R: RangeBounds<usize>,
pub fn iter_mut(&mut self) -> IterMut<'_, K, V>ⓘ[src]
pub fn retain<F>(&mut self, f: F) where
F: FnMut(&(K, V)) -> bool, [src]
F: FnMut(&(K, V)) -> bool,
pub fn into_vec(self) -> Vec<(K, V)>[src]
NOTE: to_vec() is a slice method that is accessible through deref, use this instead to avoid cloning
Methods from Deref<Target = Vec<(K, V)>>
pub fn capacity(&self) -> usize1.0.0[src]
Returns the number of elements the vector can hold without reallocating.
Examples
let vec: Vec<i32> = Vec::with_capacity(10); assert_eq!(vec.capacity(), 10);
pub fn as_slice(&self) -> &[T]1.7.0[src]
Extracts a slice containing the entire vector.
Equivalent to &s[..].
Examples
use std::io::{self, Write}; let buffer = vec![1, 2, 3, 5, 8]; io::sink().write(buffer.as_slice()).unwrap();
pub fn as_ptr(&self) -> *const T1.37.0[src]
Returns a raw pointer to the vector's buffer.
The caller must ensure that the vector outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the vector may cause its buffer to be reallocated, which would also make any pointers to it invalid.
The caller must also ensure that the memory the pointer (non-transitively) points to
is never written to (except inside an UnsafeCell) using this pointer or any pointer
derived from it. If you need to mutate the contents of the slice, use as_mut_ptr.
Examples
let x = vec![1, 2, 4]; let x_ptr = x.as_ptr(); unsafe { for i in 0..x.len() { assert_eq!(*x_ptr.add(i), 1 << i); } }
pub fn allocator(&self) -> &A[src]
allocator_api)Returns a reference to the underlying allocator.
pub fn len(&self) -> usize1.0.0[src]
Returns the number of elements in the vector, also referred to as its 'length'.
Examples
let a = vec![1, 2, 3]; assert_eq!(a.len(), 3);
pub fn is_empty(&self) -> bool1.0.0[src]
Returns true if the vector contains no elements.
Examples
let mut v = Vec::new(); assert!(v.is_empty()); v.push(1); assert!(!v.is_empty());
Trait Implementations
impl<K: Clone, V: Clone> Clone for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
impl<K: Debug, V: Debug> Debug for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
impl<K, V> Default for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
impl<K, V> Deref for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
type Target = Vec<(K, V)>
The resulting type after dereferencing.
pub fn deref(&self) -> &Vec<(K, V)>[src]
impl<K, V> Eq for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq + Eq, [src]
K: Ord + Clone + Debug,
V: PartialEq + Eq,
impl<K, V> Extend<(K, V)> for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
pub fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)[src]
pub fn extend_one(&mut self, item: A)[src]
pub fn extend_reserve(&mut self, additional: usize)[src]
impl<K, V> From<Vec<(K, V), Global>> for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
pub fn from(vec: Vec<(K, V)>) -> Self[src]
Uses sort_by_key() and dedup_by_key() to remove duplicate key entries.
Note that dedup_by_key() will keep the first of duplicate keys present
in the input vector.
impl<K, V> FromIterator<(K, V)> for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
pub fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self[src]
impl<K, V> IntoIterator for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
type Item = (K, V)
The type of the elements being iterated over.
type IntoIter = IntoIter<Self::Item>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> Self::IntoIter[src]
impl<K: PartialEq, V: PartialEq> PartialEq<KeyVec<K, V>> for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
pub fn eq(&self, other: &KeyVec<K, V>) -> bool[src]
pub fn ne(&self, other: &KeyVec<K, V>) -> bool[src]
impl<K, V> StructuralPartialEq for KeyVec<K, V> where
K: Ord + Clone + Debug,
V: PartialEq, [src]
K: Ord + Clone + Debug,
V: PartialEq,
Auto Trait Implementations
impl<K, V> RefUnwindSafe for KeyVec<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for KeyVec<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for KeyVec<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> Unpin for KeyVec<K, V> where
K: Unpin,
V: Unpin,
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for KeyVec<K, V> where
K: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut 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.
pub 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>,