Struct zerovec::varzerovec::VarZeroVecBorrowed [−][src]
pub struct VarZeroVecBorrowed<'a, T: ?Sized> { /* fields omitted */ }
Expand description
A fully-borrowed VarZeroVec
. This type has the same internal buffer representation
of VarZeroVec
, making it cheaply convertible to VarZeroVec
and VarZeroVecOwned
;
however, unlike those two, it cannot be mutated.
This is basically an &'a [u8]
to a zero copy buffer, but split out into
the buffer components. Logically this is capable of behaving as
a &'a [T::VarULE]
, but since T::VarULE
is unsized that type does not actually
exist.
See VarZeroVecBorrowed::parse_byte_slice()
for information on the internal invariants involved
Implementations
Construct a new VarZeroVecBorrowed, checking invariants about the overall buffer size:
- There must be either zero or at least four bytes (if four, this is the “length” parsed as a usize)
- There must be at least
4*length + 4
bytes total, to form the the arrayindices
of indices indices[i]..indices[i+1]
must index into a valid section ofthings
, such that it parses to aT::VarULE
indices[len - 1]..things.len()
must index into a valid section ofthings
, such that it parses to aT::VarULE
Construct a VarZeroVecBorrowed
from a byte slice that has previously
successfully returned a VarZeroVecBorrowed
when passed to
VarZeroVecBorrowed::parse_byte_slice()
. Will return the same
object as one would get from calling VarZeroVecBorrowed::parse_byte_slice()
.
Safety
The bytes must have previously successfully run through
VarZeroVecBorrowed::parse_byte_slice()
Get a reference to the entire backing buffer of this vector
Get the idx’th element out of this slice. Returns None
if out of bounds.
Create an iterator over the Ts contained in VarZeroVecBorrowed
Binary searches a sorted VarZeroVecBorrowed<T>
for the given element. For more information, see
the primitive function binary_search
.
Trait Implementations
Performs the conversion.
Performs the conversion.
Auto Trait Implementations
impl<'a, T: ?Sized> RefUnwindSafe for VarZeroVecBorrowed<'a, T> where
T: RefUnwindSafe,
impl<'a, T: ?Sized> Send for VarZeroVecBorrowed<'a, T> where
T: Sync,
impl<'a, T: ?Sized> Sync for VarZeroVecBorrowed<'a, T> where
T: Sync,
impl<'a, T: ?Sized> Unpin for VarZeroVecBorrowed<'a, T>
impl<'a, T: ?Sized> UnwindSafe for VarZeroVecBorrowed<'a, T> where
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more