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 array indices of indices
  • indices[i]..indices[i+1] must index into a valid section of things, such that it parses to a T::VarULE
  • indices[len - 1]..things.len() must index into a valid section of things, such that it parses to a T::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 the number of elements in this vector

Returns true if the vector contains no elements.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Performs the conversion.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.