Skip to main content

MapContext

Struct MapContext 

Source
pub struct MapContext<E: Entry, C: Converter> { /* private fields */ }
Expand description

The common implementation of all map-like contexts.

Implementations§

Source§

impl<E: Entry, C: Converter> MapContext<E, C>

Source

pub fn new() -> Self

Creates a new MapContext.

Trait Implementations§

Source§

impl<E: Entry, C: Converter> AbstractContext for MapContext<E, C>

Source§

type Key = <E as Entry>::Key

The key of each entry.
Source§

type Value = <E as Entry>::Value

The value of each entry.
Source§

type Entry = E

The entry stored in this context.
Source§

type Iter<'a> = CommonIter<'a, E, Iter<'a, E>> where E: 'a

The iterator over this context’s entries.
Source§

fn iter(&self) -> Self::Iter<'_>

Returns the context’s iterator.
Source§

impl<E: Entry, C: Converter> Context for MapContext<E, C>

Source§

type Converter = C

The default converter used by the context, which transforms values to AbstractContext::Value before insertions.
Source§

fn insert<Q, R>(&mut self, key: Q, value: R)
where Q: Into<Self::Key>, R: Into<Self::Value>,

Inserts the context information represented as a key-value pair. Any types that are compatible with AbstractContext::Key and AbstractContext::Value through the Into trait respectively are expected.
Source§

fn get<Q>(&self, key: &Q) -> Option<&<Self::Entry as Entry>::ValueBorrowed>
where <Self::Entry as Entry>::KeyBorrowed: Borrow<Q>, Q: Debug + Eq + Hash + ?Sized,

Returns the value corresponding to the given key.
Source§

fn insert_with<C, Q, R>(&mut self, key: Q, value: R)
where Q: Into<Self::Key>, C: Converter, R: Convertable<C, Self::Value>,

Converts the context information represented as a key-value pair using the specified converter C and then inserts the converted pair. Any types that are compatible with AbstractContext::Key and AbstractContext::Value through the Into and Convertable trait respectively are expected.
Source§

impl<E: Debug + Entry, C: Debug + Converter> Debug for MapContext<E, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: Entry, C: Converter> Default for MapContext<E, C>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<E: Eq + Entry, C: Eq + Converter> Eq for MapContext<E, C>

Source§

impl<E: Entry, C: Converter, Q, R> From<Vec<(Q, R)>> for MapContext<E, C>
where Q: Into<<Self as AbstractContext>::Key>, R: Into<<Self as AbstractContext>::Value>,

Source§

fn from(entries: Vec<(Q, R)>) -> Self

Converts to this type from the input type.
Source§

impl<E: Entry, C: Converter> From<Vec<E>> for MapContext<E, C>

Source§

fn from(entries: Vec<E>) -> Self

Converts to this type from the input type.
Source§

impl<E: Entry, C: Converter, Q, R> FromIterator<(Q, R)> for MapContext<E, C>
where Q: Into<<Self as AbstractContext>::Key>, R: Into<<Self as AbstractContext>::Value>,

Source§

fn from_iter<T: IntoIterator<Item = (Q, R)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<E: Entry, C: Converter> FromIterator<E> for MapContext<E, C>

Source§

fn from_iter<T: IntoIterator<Item = E>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<E: PartialEq + Entry, C: PartialEq + Converter> PartialEq for MapContext<E, C>

Source§

fn eq(&self, other: &MapContext<E, C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<E: PartialEq + Entry, C: PartialEq + Converter> StructuralPartialEq for MapContext<E, C>

Auto Trait Implementations§

§

impl<E, C> Freeze for MapContext<E, C>

§

impl<E, C> RefUnwindSafe for MapContext<E, C>

§

impl<E, C> Send for MapContext<E, C>

§

impl<E, C> Sync for MapContext<E, C>

§

impl<E, C> Unpin for MapContext<E, C>
where C: Unpin, E: Unpin,

§

impl<E, C> UnsafeUnpin for MapContext<E, C>

§

impl<E, C> UnwindSafe for MapContext<E, C>
where C: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyValue for T
where T: Any + Debug + Send + Sync,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to itself as a trait object of the Any trait, i.e. upcasts itself to a trait object of Any.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S, T> Convertable<BoxConverter, T> for S
where S: AnyValue, T: From<Box<dyn AnyValue + Sync + Send>>,

Source§

fn to(self) -> T

Converts the value into another type T using the specified converter C. The conversion should not fail, so not a Result<T, E> but a T is expected. Read more
Source§

impl<S, T> Convertable<DebugConverter, T> for S
where S: Debug, T: From<String>,

Source§

fn to(self) -> T

Converts the value into another type T using the specified converter C. The conversion should not fail, so not a Result<T, E> but a T is expected. Read more
Source§

impl<S, T> Convertable<IntoConverter, T> for S
where S: Into<T>,

Source§

fn to(self) -> T

Converts the value into another type T using the specified converter C. The conversion should not fail, so not a Result<T, E> but a T is expected. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.