Struct ZeroMap2dBorrowed
struct ZeroMap2dBorrowed<'a, K0, K1, V> { ... }
where
K0: ZeroMapKV<'a> + ?Sized,
K1: ZeroMapKV<'a> + ?Sized,
V: ZeroMapKV<'a> + ?Sized
A borrowed-only version of ZeroMap2d
This is useful for fully-zero-copy deserialization from non-human-readable
serialization formats. It also has the advantage that it can return references that live for
the lifetime of the backing buffer as opposed to that of the ZeroMap2dBorrowed instance.
Examples
use ZeroMap2dBorrowed;
// Example byte buffer representing the map { 1: {2: "three" } }
let BINCODE_BYTES: & = &;
// Deserializing to ZeroMap2d requires no heap allocations.
let zero_map: =
deserialize
.expect;
assert_eq!;
This can be obtained from a ZeroMap2d via ZeroMap2d::as_borrowed
Implementations
impl<'a, K0, K1, V> ZeroMap2dBorrowed<'a, K0, K1, V>
fn get0<'l>(self: &'l Self, key0: &K0) -> Option<ZeroMap2dCursor<'a, 'a, K0, K1, V>>Gets a cursor for
key0. IfNone, thenkey0is not in the map. IfSome, thenkey0is in the map, andkey1can be queried.use ZeroMap2d; let mut map = new; map.insert; map.insert; let borrowed = map.as_borrowed; assert!; assert!;fn get0_by<'l, impl FnMut(&K0) -> Ordering: FnMut(&K0) -> Ordering>(self: &'l Self, predicate: impl FnMut(&K0) -> Ordering) -> Option<ZeroMap2dCursor<'a, 'a, K0, K1, V>>Binary search the map for
key0, returning a cursor.use ZeroMap2d; let mut map = new; map.insert; map.insert; let borrowed = map.as_borrowed; assert!; assert!;fn contains_key0(self: &Self, key0: &K0) -> boolReturns whether
key0is contained in this mapuse ZeroMap2d; let mut map = new; map.insert; map.insert; let borrowed = map.as_borrowed; assert!; assert!;
impl<'a, K0, K1, V> ZeroMap2dBorrowed<'a, K0, K1, V>
fn get_2d(self: &Self, key0: &K0, key1: &K1) -> Option<&'a <V as >::GetType>Get the value associated with
key0andkey1, if it exists.This is able to return values that live longer than the map itself since they borrow directly from the backing buffer. This is the primary advantage of using
ZeroMap2dBorrowedoverZeroMap2d.use ZeroMap2d; let mut map = new; map.insert; map.insert; map.insert; let borrowed = map.as_borrowed; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!;
impl<'a, K0, K1, V> ZeroMap2dBorrowed<'a, K0, K1, V>
fn new() -> SelfCreates a new, empty
ZeroMap2dBorrowed<K0, K1, V>.Note: Since
ZeroMap2dBorrowedis not mutable, the return value will be a stub unless converted into aZeroMap2d.Examples
use ZeroMap2dBorrowed; let zm: = new; assert!;
impl<'a, K0, K1, V> ZeroMap2dBorrowed<'a, K0, K1, V>
fn len(self: &Self) -> usizeThe number of elements in the
ZeroMap2dBorrowedfn is_empty(self: &Self) -> boolWhether the
ZeroMap2dBorrowedis empty
impl<'a, K0, K1, V> ZeroMap2dBorrowed<'a, K0, K1, V>
fn get_copied_2d(self: &Self, key0: &K0, key1: &K1) -> Option<V>For cases when
Vis fixed-size, obtain a direct copy ofVinstead ofV::ULE
impl<'a, K0, K1, V> ZeroMap2dBorrowed<'a, K0, K1, V>
fn iter0<'l>(self: &'l Self) -> impl Iterator<Item = ZeroMap2dCursor<'a, 'a, K0, K1, V>> + 'lProduce an ordered iterator over keys0
impl<'a, 'b, K0, K1, V> PartialEq for ZeroMap2dBorrowed<'a, K0, K1, V>
fn eq(self: &Self, other: &ZeroMap2dBorrowed<'b, K0, K1, V>) -> bool
impl<'a, K0, K1, V> Clone for ZeroMap2dBorrowed<'a, K0, K1, V>
fn clone(self: &Self) -> Self
impl<'a, K0, K1, V> Copy for ZeroMap2dBorrowed<'a, K0, K1, V>
impl<'a, K0, K1, V> Debug for ZeroMap2dBorrowed<'a, K0, K1, V>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result<(), Error>
impl<'a, K0, K1, V> Default for ZeroMap2dBorrowed<'a, K0, K1, V>
fn default() -> Self
impl<'a, K0, K1, V> Freeze for ZeroMap2dBorrowed<'a, K0, K1, V>
impl<'a, K0, K1, V> RefUnwindSafe for ZeroMap2dBorrowed<'a, K0, K1, V>
impl<'a, K0, K1, V> Send for ZeroMap2dBorrowed<'a, K0, K1, V>
impl<'a, K0, K1, V> Sync for ZeroMap2dBorrowed<'a, K0, K1, V>
impl<'a, K0, K1, V> Unpin for ZeroMap2dBorrowed<'a, K0, K1, V>
impl<'a, K0, K1, V> UnsafeUnpin for ZeroMap2dBorrowed<'a, K0, K1, V>
impl<'a, K0, K1, V> UnwindSafe for ZeroMap2dBorrowed<'a, K0, K1, V>
impl<'a, K0, K1, V> Yokeable for ZeroMap2dBorrowed<'static, K0, K1, V>
fn transform(self: &'a Self) -> &'a <Self as >::Outputfn transform_owned(self: Self) -> <Self as >::Outputunsafe fn make(from: <Self as >::Output) -> Selffn transform_mut<F>(self: &'a mut Self, f: F) where F: 'static + for<'b> FnOnce(&'b mut <Self as >::Output)
impl<T> Any for ZeroMap2dBorrowed<'a, K0, K1, V>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for ZeroMap2dBorrowed<'a, K0, K1, V>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for ZeroMap2dBorrowed<'a, K0, K1, V>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for ZeroMap2dBorrowed<'a, K0, K1, V>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> ErasedDestructor for ZeroMap2dBorrowed<'a, K0, K1, V>
impl<T> From for ZeroMap2dBorrowed<'a, K0, K1, V>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for ZeroMap2dBorrowed<'a, K0, K1, V>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for ZeroMap2dBorrowed<'a, K0, K1, V>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for ZeroMap2dBorrowed<'a, K0, K1, V>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for ZeroMap2dBorrowed<'a, K0, K1, V>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>