Trait salsa::InternValue

source ·
pub trait InternValue {
    type Key: Eq + Hash + Debug + Clone;

    // Required method
    fn into_key(&self) -> Self::Key;

    // Provided method
    fn with_key<F: FnOnce(&Self::Key) -> T, T>(&self, f: F) -> T { ... }
}
Expand description

Trait implemented for the “value” that is being interned.

Required Associated Types§

source

type Key: Eq + Hash + Debug + Clone

They key used to intern this value by.

Required Methods§

source

fn into_key(&self) -> Self::Key

Maps the value to a key that will be used to intern it.

Provided Methods§

source

fn with_key<F: FnOnce(&Self::Key) -> T, T>(&self, f: F) -> T

Calls the given function with the key that was used to intern this value.

This is mainly used to prevent frequent cloning of the key when doing a lookup.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<A: InternValue + Eq + Hash + Debug + Clone, B: InternValue + Eq + Hash + Debug + Clone> InternValue for (A, B)

§

type Key = (A, B)

source§

fn into_key(&self) -> Self::Key

source§

fn with_key<F: FnOnce(&Self::Key) -> T, T>(&self, f: F) -> T

Implementors§

source§

impl<V: InternValueTrivial> InternValue for V

Implement InternValue trivially, that is without actually mapping at all.

§

type Key = V