pub trait Container {
type Key;
type Value;
// Required methods
fn values(&self) -> &[Self::Value];
fn selectors(&self) -> &BTreeMap<Self::Key, Selector<Self::Value>>;
fn with_preset<V, P>(
preset: &P,
selectors: BTreeMap<Self::Key, Selector<Self::Value>>,
) -> Self
where V: Into<Self::Value>,
P: Preset<Value = V>;
fn with_presets<V, P>(
presets: &[P],
selectors: BTreeMap<Self::Key, Selector<Self::Value>>,
) -> Self
where V: Into<Self::Value>,
P: Preset<Value = V>;
// Provided methods
fn len(&self) -> usize { ... }
fn is_empty(&self) -> bool { ... }
fn by_index(&self, index: usize) -> Option<&Self::Value> { ... }
fn get<K: Into<Self::Key>>(&self, key: K) -> Option<&Self::Value>
where Self::Key: Ord { ... }
}
Expand description
A container of a slice of values (usually a vector) that are accessible by index, but also by means of a mapping of keys to selectors. The selector states whether to use the key’s order to access the values, a given index or even a completely overridden value that is not in the list of values. Values are re-used in a carousel fashion using the modulo operator for indices or orders that are out of bounds.
Required Associated Types§
Required Methods§
Sourcefn selectors(&self) -> &BTreeMap<Self::Key, Selector<Self::Value>>
fn selectors(&self) -> &BTreeMap<Self::Key, Selector<Self::Value>>
The mapping of key to selector. A selector is an entry’s index or an override.
Sourcefn with_preset<V, P>(
preset: &P,
selectors: BTreeMap<Self::Key, Selector<Self::Value>>,
) -> Self
fn with_preset<V, P>( preset: &P, selectors: BTreeMap<Self::Key, Selector<Self::Value>>, ) -> Self
Create this palette from a preset.
fn with_presets<V, P>( presets: &[P], selectors: BTreeMap<Self::Key, Selector<Self::Value>>, ) -> Self
Provided Methods§
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.