MapTrait

Trait MapTrait 

Source
pub trait MapTrait {
    type Key;
    type Value;

    const KEY_IDENT: &str = "key";
    const VALUE_IDENT: &str = "value";
    const DESCRIPTION: Option<&str> = None;
}
Expand description

Trait defining contract for types that can be represented as maps

§Examples

Implementing for a custom collection:

use google_ai_rs::MapTrait;

struct PairList<K, V>(Vec<(K, V)>);

impl<K, V> MapTrait for PairList<K, V> {
    type Key = K;
    type Value = V;
    const KEY_IDENT: &str = "k";
    const VALUE_IDENT: &str = "v";
}

Provided Associated Constants§

Source

const KEY_IDENT: &str = "key"

Source

const VALUE_IDENT: &str = "value"

Source

const DESCRIPTION: Option<&str> = None

Required Associated Types§

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<K, V> MapTrait for HashMap<K, V>

Source§

type Key = K

Source§

type Value = V

Implementors§