mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-01-09 14:48:16 -05:00
Derive clone for ConstraintRef (#3241)
Derives `Clone` (and some other traits) for `ConstraintRef`. Since it is a reference, it should implement Clone. Note that `Clone` for `AlgebraicConstraint` is only auto-derived if `V` is `Clone`, which is the case if `V` is a reference.
This commit is contained in:
@@ -222,7 +222,7 @@ fn remove_free_variables<T: FieldElement, V: Clone + Ord + Eq + Hash + Display>(
|
||||
.filter(|(variable, constraint)| match constraint {
|
||||
// Remove the algebraic constraint if we can solve for the variable.
|
||||
ConstraintRef::AlgebraicConstraint(constr) => {
|
||||
can_always_be_satisfied_via_free_variable(constr.clone(), variable)
|
||||
can_always_be_satisfied_via_free_variable(*constr, variable)
|
||||
}
|
||||
ConstraintRef::BusInteraction(bus_interaction) => {
|
||||
let bus_id = bus_interaction.bus_id.try_to_number().unwrap();
|
||||
|
||||
@@ -10,7 +10,7 @@ use num_traits::{One, Zero};
|
||||
pub mod solve;
|
||||
|
||||
/// An algebraic constraint
|
||||
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub struct AlgebraicConstraint<V> {
|
||||
/// The expression representing the constraint, which must evaluate to 0 for the constraint to be satisfied.
|
||||
pub expression: V,
|
||||
|
||||
@@ -267,6 +267,7 @@ impl<T: FieldElement> BusInteractionHandler<T> for DefaultBusInteractionHandler<
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum ConstraintRef<'a, T, V> {
|
||||
AlgebraicConstraint(AlgebraicConstraint<&'a GroupedExpression<T, V>>),
|
||||
BusInteraction(&'a BusInteraction<GroupedExpression<T, V>>),
|
||||
|
||||
@@ -364,7 +364,7 @@ where
|
||||
while let Some(item) = self.constraint_system.pop_front() {
|
||||
let effects = match item {
|
||||
ConstraintRef::AlgebraicConstraint(c) => {
|
||||
if let Some((v1, expr)) = try_to_simple_equivalence(c.clone()) {
|
||||
if let Some((v1, expr)) = try_to_simple_equivalence(c) {
|
||||
self.apply_assignment(&v1, &expr);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user