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§
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>
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.