Trait ZeroVecLike

trait ZeroVecLike<T: ?Sized>

Trait abstracting over ZeroVec and VarZeroVec, for use in ZeroMap. You should not be implementing or calling this trait directly.

The T type is the type received by [Self::zvl_binary_search()], as well as the one used for human-readable serialization.

Methods are prefixed with zvl_* to avoid clashes with methods on the types themselves

Associated Types

type GetType: TraitBound { trait_: Path { path: "Sized", id: Id(6), args: None }, generic_params: [], modifier: Maybe } + Outlives("'static")

The type returned by Self::get()

type SliceVariant: TraitBound { trait_: Path { path: "ZeroVecLike", id: Id(190), args: Some(AngleBracketed { args: [Type(Generic("T"))], constraints: [AssocItemConstraint { name: "GetType", args: None, binding: Equality(Type(QualifiedPath { name: "GetType", args: None, self_type: Generic("Self"), trait_: Some(Path { path: "", id: Id(190), args: None }) })) }] }) }, generic_params: [], modifier: None } + TraitBound { trait_: Path { path: "Sized", id: Id(6), args: None }, generic_params: [], modifier: Maybe }

A fully borrowed version of this

Required Methods

fn zvl_new_borrowed() -> &'static <Self as >::SliceVariant

Create a new, empty borrowed variant

Search for a key in a sorted vector, returns Ok(index) if found, returns Err(insert_index) if not found, where insert_index is the index where it should be inserted to maintain sort order.

fn zvl_binary_search_in_range(self: &Self, k: &T, range: Range<usize>) -> Option<Result<usize, usize>>
where
    T: Ord

Search for a key within a certain range in a sorted vector. Returns None if the range is out of bounds, and Ok or Err in the same way as zvl_binary_search. Indices are returned relative to the start of the range.

fn zvl_binary_search_by<impl FnMut(&T) -> Ordering: FnMut(&T) -> Ordering>(self: &Self, predicate: impl FnMut(&T) -> Ordering) -> Result<usize, usize>

Search for a key in a sorted vector by a predicate, returns Ok(index) if found, returns Err(insert_index) if not found, where insert_index is the index where it should be inserted to maintain sort order.

fn zvl_binary_search_in_range_by<impl FnMut(&T) -> Ordering: FnMut(&T) -> Ordering>(self: &Self, predicate: impl FnMut(&T) -> Ordering, range: Range<usize>) -> Option<Result<usize, usize>>

Search for a key within a certain range in a sorted vector by a predicate. Returns None if the range is out of bounds, and Ok or Err in the same way as zvl_binary_search. Indices are returned relative to the start of the range.

fn zvl_get(self: &Self, index: usize) -> Option<&<Self as >::GetType>

Get element at index

fn zvl_len(self: &Self) -> usize

The length of this vector

fn zvl_as_borrowed(self: &Self) -> &<Self as >::SliceVariant

Construct a borrowed variant by borrowing from &self.

This function behaves like &'b self -> Self::SliceVariant<'b>, where 'b is the lifetime of the reference to this object.

Note: We rely on the compiler recognizing 'a and 'b as covariant and casting &'b Self<'a> to &'b Self<'b> when this gets called, which works out for ZeroVec and VarZeroVec containers just fine.

fn zvl_get_as_t<R, impl FnOnce(&T) -> R: FnOnce(&T) -> R>(g: &<Self as >::GetType, f: impl FnOnce(&T) -> R) -> R

Obtain a reference to T, passed to a closure

This uses a callback because it's not possible to return owned-or-borrowed types without GATs

Impls should guarantee that the callback function is be called exactly once.

Provided Methods

fn zvl_is_ascending(self: &Self) -> bool
where
    T: Ord

Check if this vector is in ascending order according to Ts Ord impl

fn zvl_is_empty(self: &Self) -> bool

Check if this vector is empty

fn t_cmp_get(t: &T, g: &<Self as >::GetType) -> Ordering
where
    T: Ord

Compare this type with a Self::GetType. This must produce the same result as if g were converted to Self

fn get_cmp_get(a: &<Self as >::GetType, b: &<Self as >::GetType) -> Ordering
where
    T: Ord

Compare two values of Self::GetType. This must produce the same result as if both a and b were converted to Self

Implementors