Skip to main content

FromIndexKey

Trait FromIndexKey 

Source
pub trait FromIndexKey: Sized {
    // Required method
    fn from_index_key(k: &IndexKey) -> Self;
}
Expand description

Typed projection of an IndexKey. Implementations panic when the key’s shape does not match the target type, the same contract as crate::indexed::IndexedVar indexing on a missing key.

Used by crate::model::Model::add_constraints_over (and similar rule helpers) to give the closure typed indices directly:

m.add_constraints_over("supply", &(&plants * &markets), |(p, m): (String, String)| {
    // p, m are native String, no manual unpack
    ...
});

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

Implementations on Foreign Types§

Source§

impl FromIndexKey for i32

Source§

impl FromIndexKey for i64

Source§

impl FromIndexKey for usize

Source§

impl FromIndexKey for String

Source§

impl<A, B> FromIndexKey for (A, B)

Source§

impl<A, B, C> FromIndexKey for (A, B, C)

Source§

impl<A, B, C, D> FromIndexKey for (A, B, C, D)

Implementors§