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 >::SliceVariantCreate a new, empty borrowed variant
fn zvl_binary_search(self: &Self, k: &T) -> Result<usize, usize> where T: OrdSearch for a key in a sorted vector, returns
Ok(index)if found, returnsErr(insert_index)if not found, whereinsert_indexis 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: OrdSearch for a key within a certain range in a sorted vector. Returns
Noneif the range is out of bounds, andOkorErrin the same way aszvl_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, returnsErr(insert_index)if not found, whereinsert_indexis 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
Noneif the range is out of bounds, andOkorErrin the same way aszvl_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
indexfn zvl_len(self: &Self) -> usizeThe length of this vector
fn zvl_as_borrowed(self: &Self) -> &<Self as >::SliceVariantConstruct a borrowed variant by borrowing from
&self.This function behaves like
&'b self -> Self::SliceVariant<'b>, where'bis the lifetime of the reference to this object.Note: We rely on the compiler recognizing
'aand'bas covariant and casting&'b Self<'a>to&'b Self<'b>when this gets called, which works out forZeroVecandVarZeroVeccontainers just fine.fn zvl_get_as_t<R, impl FnOnce(&T) -> R: FnOnce(&T) -> R>(g: &<Self as >::GetType, f: impl FnOnce(&T) -> R) -> RObtain 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: OrdCheck if this vector is in ascending order according to
TsOrdimplfn zvl_is_empty(self: &Self) -> boolCheck if this vector is empty
fn t_cmp_get(t: &T, g: &<Self as >::GetType) -> Ordering where T: OrdCompare this type with a
Self::GetType. This must produce the same result as ifgwere converted toSelffn get_cmp_get(a: &<Self as >::GetType, b: &<Self as >::GetType) -> Ordering where T: OrdCompare two values of
Self::GetType. This must produce the same result as if bothaandbwere converted toSelf
Implementors
impl<T> ZeroVecLike for ZeroSlice<T>impl<T, F> ZeroVecLike for VarZeroSlice<T, F>impl<'a, T, F> ZeroVecLike for VarZeroVec<'a, T, F>impl<'a, T> ZeroVecLike for ZeroVec<'a, T>