Trait MapKey

Source
pub trait MapKey: Clone {
    type MapTy<V>;
    type Values<V>: Iterator<Item = V>;

    // Required methods
    fn k_from_fn<V>(f: impl FnMut(Self) -> V) -> Self::MapTy<V>;
    fn k_as_ref<V>(this: &Self::MapTy<V>) -> Self::MapTy<&V>;
    fn k_as_mut<V>(this: &mut Self::MapTy<V>) -> Self::MapTy<&mut V>;
    fn k_map<V, W>(
        this: Self::MapTy<V>,
        f: impl FnMut(V) -> W,
    ) -> Self::MapTy<W>;
    fn k_map_with_key<V, W>(
        this: Self::MapTy<V>,
        f: impl FnMut(Self, V) -> W,
    ) -> Self::MapTy<W>;
    fn k_zip_with<V1, V2, W>(
        a: Self::MapTy<V1>,
        b: Self::MapTy<V2>,
        f: impl FnMut(V1, V2) -> W,
    ) -> Self::MapTy<W>;
    fn k_index<'a, V: 'a>(this: &'a Self::MapTy<V>, k: &Self) -> &'a V;
    fn k_index_mut<'a, V: 'a>(
        this: &'a mut Self::MapTy<V>,
        k: &Self,
    ) -> &'a mut V;
    fn k_into_values<V>(this: Self::MapTy<V>) -> Self::Values<V>;
}
Expand description

可以作为键者

建议使用 GenericMapKey 自动实现。

Required Associated Types§

Source

type MapTy<V>

Source

type Values<V>: Iterator<Item = V>

Required Methods§

Source

fn k_from_fn<V>(f: impl FnMut(Self) -> V) -> Self::MapTy<V>

Source

fn k_as_ref<V>(this: &Self::MapTy<V>) -> Self::MapTy<&V>

Source

fn k_as_mut<V>(this: &mut Self::MapTy<V>) -> Self::MapTy<&mut V>

Source

fn k_map<V, W>(this: Self::MapTy<V>, f: impl FnMut(V) -> W) -> Self::MapTy<W>

Source

fn k_map_with_key<V, W>( this: Self::MapTy<V>, f: impl FnMut(Self, V) -> W, ) -> Self::MapTy<W>

Source

fn k_zip_with<V1, V2, W>( a: Self::MapTy<V1>, b: Self::MapTy<V2>, f: impl FnMut(V1, V2) -> W, ) -> Self::MapTy<W>

Source

fn k_index<'a, V: 'a>(this: &'a Self::MapTy<V>, k: &Self) -> &'a V

Source

fn k_index_mut<'a, V: 'a>(this: &'a mut Self::MapTy<V>, k: &Self) -> &'a mut V

Source

fn k_into_values<V>(this: Self::MapTy<V>) -> Self::Values<V>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl MapKey for i8

Source§

type MapTy<V> = [V; 256]

Source§

type Values<V> = IntoIter<V, LEN>

Source§

fn k_from_fn<V>(f: impl FnMut(Self) -> V) -> Self::MapTy<V>

Source§

fn k_as_ref<V>(this: &Self::MapTy<V>) -> Self::MapTy<&V>

Source§

fn k_as_mut<V>(this: &mut Self::MapTy<V>) -> Self::MapTy<&mut V>

Source§

fn k_map<V, W>(this: Self::MapTy<V>, f: impl FnMut(V) -> W) -> Self::MapTy<W>

Source§

fn k_map_with_key<V, W>( this: Self::MapTy<V>, f: impl FnMut(Self, V) -> W, ) -> Self::MapTy<W>

Source§

fn k_zip_with<V1, V2, W>( a: Self::MapTy<V1>, b: Self::MapTy<V2>, f: impl FnMut(V1, V2) -> W, ) -> Self::MapTy<W>

Source§

fn k_index<'a, V: 'a>(this: &'a Self::MapTy<V>, k: &Self) -> &'a V

Source§

fn k_index_mut<'a, V: 'a>(this: &'a mut Self::MapTy<V>, k: &Self) -> &'a mut V

Source§

fn k_into_values<V>(this: Self::MapTy<V>) -> Self::Values<V>

Source§

impl MapKey for u8

Source§

type MapTy<V> = [V; 256]

Source§

type Values<V> = IntoIter<V, LEN>

Source§

fn k_from_fn<V>(f: impl FnMut(Self) -> V) -> Self::MapTy<V>

Source§

fn k_as_ref<V>(this: &Self::MapTy<V>) -> Self::MapTy<&V>

Source§

fn k_as_mut<V>(this: &mut Self::MapTy<V>) -> Self::MapTy<&mut V>

Source§

fn k_map<V, W>(this: Self::MapTy<V>, f: impl FnMut(V) -> W) -> Self::MapTy<W>

Source§

fn k_map_with_key<V, W>( this: Self::MapTy<V>, f: impl FnMut(Self, V) -> W, ) -> Self::MapTy<W>

Source§

fn k_zip_with<V1, V2, W>( a: Self::MapTy<V1>, b: Self::MapTy<V2>, f: impl FnMut(V1, V2) -> W, ) -> Self::MapTy<W>

Source§

fn k_index<'a, V: 'a>(this: &'a Self::MapTy<V>, k: &Self) -> &'a V

Source§

fn k_index_mut<'a, V: 'a>(this: &'a mut Self::MapTy<V>, k: &Self) -> &'a mut V

Source§

fn k_into_values<V>(this: Self::MapTy<V>) -> Self::Values<V>

Implementors§

Source§

impl<T: GenericMapKey> MapKey for T
where T::Repr: GMapKey,

Source§

type MapTy<V> = <<T as Generic>::Repr as GMapKey>::MapTy<V>

Source§

type Values<V> = <<T as Generic>::Repr as GMapKey>::Values<V>