Trait oxidd_core::util::Substitution
source · pub trait Substitution {
type Var;
type Replacement;
// Required methods
fn id(&self) -> u32;
fn pairs(
&self,
) -> impl ExactSizeIterator<Item = (Self::Var, Self::Replacement)>;
// Provided method
fn map<V, R, F>(&self, f: F) -> MapSubst<'_, Self, F>
where F: Fn((Self::Var, Self::Replacement)) -> (V, R) { ... }
}Expand description
Substitution mapping variables to replacement functions
The intent behind substitution structs is to optimize the case where the
same substitution is applied multiple times. We would like to re-use apply
cache entries across these operations, and therefore, we need a compact
identifier for the substitution (provided by Self::id() here).
To create a substitution, you’ll probably want to use Subst::new().
Required Associated Types§
sourcetype Replacement
type Replacement
Replacement type
Required Methods§
sourcefn id(&self) -> u32
fn id(&self) -> u32
Get the ID of this substitution
This unique identifier may safely be used as part of a cache key, i.e., two different substitutions to be used with one manager must not have the same ID. (That two equal substitutions have the same ID would be ideal but is not required for correctness.)
sourcefn pairs(&self) -> impl ExactSizeIterator<Item = (Self::Var, Self::Replacement)>
fn pairs(&self) -> impl ExactSizeIterator<Item = (Self::Var, Self::Replacement)>
Iterate over pairs of variable and replacement
Provided Methods§
sourcefn map<V, R, F>(&self, f: F) -> MapSubst<'_, Self, F>
fn map<V, R, F>(&self, f: F) -> MapSubst<'_, Self, F>
Map the substitution, e.g., to use different variable and replacement types
f should be injective with respect to variables (the first component),
i.e., two different variables should not be mapped to one. This is
required to preserve that the substitution is a mapping from variables
to replacement functions.