#[non_exhaustive]pub struct Reduction {
pub new_expression: Expression,
pub new_top: Vec<Expression>,
pub symbols: SymbolTable,
}Expand description
Represents the result of applying a rule to an expression within a model.
A Reduction encapsulates the changes made to a model during a rule application.
It includes a new expression to replace the original one, an optional top-level constraint
to be added to the model, and any updates to the model’s symbol table.
This struct allows for representing side-effects of rule applications, ensuring that all modifications, including symbol table expansions and additional constraints, are accounted for and can be applied to the model consistently.
§Fields
new_expression: The updatedExpressionthat replaces the original one after applying the rule.new_top: An additional top-levelVec<Expression>constraint that should be added to the model. If no top-level constraint is needed, this field can be set to an empty vectorVec::new().symbols: ASymbolTablecontaining any new symbol definitions or modifications to be added to the model’s symbol table. If no symbols are modified, this field can be set to an empty symbol table.
§Usage
A Reduction can be created using one of the provided constructors:
Reduction::new: Creates a reduction with a new expression, top-level constraint, and symbol modifications.Reduction::pure: Creates a reduction with only a new expression and no side-effects on the symbol table or constraints.Reduction::with_symbols: Creates a reduction with a new expression and symbol table modifications, but no top-level constraint.Reduction::with_top: Creates a reduction with a new expression and a top-level constraint, but no symbol table modifications.
The apply method allows for applying the changes represented by the Reduction to a [Model].
§Example
// Need to add an example§See Also
ApplicationResult: Represents the result of applying a rule, which may either be aReductionor anApplicationError.- [
Model]: The structure to which theReductionchanges are applied.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.new_expression: Expression§new_top: Vec<Expression>§symbols: SymbolTableImplementations§
Source§impl Reduction
impl Reduction
pub fn new( new_expression: Expression, new_top: Vec<Expression>, symbols: SymbolTable, ) -> Reduction
Sourcepub fn pure(new_expression: Expression) -> Reduction
pub fn pure(new_expression: Expression) -> Reduction
Represents a reduction with no side effects on the model.
Sourcepub fn with_symbols(
new_expression: Expression,
symbols: SymbolTable,
) -> Reduction
pub fn with_symbols( new_expression: Expression, symbols: SymbolTable, ) -> Reduction
Represents a reduction that also modifies the symbol table.
Sourcepub fn with_top(
new_expression: Expression,
new_top: Vec<Expression>,
) -> Reduction
pub fn with_top( new_expression: Expression, new_top: Vec<Expression>, ) -> Reduction
Represents a reduction that also adds a top-level constraint to the model.
Sourcepub fn added_symbols(&self, initial_symbols: &SymbolTable) -> BTreeSet<Name>
pub fn added_symbols(&self, initial_symbols: &SymbolTable) -> BTreeSet<Name>
Gets symbols added by this reduction
Sourcepub fn changed_symbols(
&self,
initial_symbols: &SymbolTable,
) -> Vec<(Name, DeclarationPtr, DeclarationPtr)>
pub fn changed_symbols( &self, initial_symbols: &SymbolTable, ) -> Vec<(Name, DeclarationPtr, DeclarationPtr)>
Gets symbols changed by this reduction
Returns a list of tuples of (name, domain before reduction, domain after reduction)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Reduction
impl !RefUnwindSafe for Reduction
impl !Send for Reduction
impl !Sync for Reduction
impl Unpin for Reduction
impl !UnwindSafe for Reduction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 184 bytes