From 9d6c6ce874ee1de6ac8415e9fc04ca158578543b Mon Sep 17 00:00:00 2001 From: Yihong Zhang Date: Wed, 23 Oct 2024 00:52:20 -0700 Subject: [PATCH] fmt --- src/actions.rs | 10 +++--- src/constraint.rs | 13 ++++--- src/lib.rs | 18 ++++++++-- src/sort/fn.rs | 6 ++-- src/sort/i64.rs | 7 +++- src/sort/map.rs | 70 ++++++++++++++++++++++++++++++++------ src/sort/mod.rs | 7 +++- src/sort/set.rs | 84 +++++++++++++++++++++++++++++++++++++++------- src/sort/string.rs | 14 ++++++-- src/sort/unit.rs | 7 +++- src/sort/vec.rs | 84 +++++++++++++++++++++++++++++++++++++++------- 11 files changed, 263 insertions(+), 57 deletions(-) diff --git a/src/actions.rs b/src/actions.rs index 41d8635c..94ad902b 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -97,10 +97,8 @@ impl<'a> ActionCompiler<'a> { } fn do_prim(&mut self, prim: &SpecializedPrimitive) { - self.instructions.push(Instruction::CallPrimitive( - prim.clone(), - prim.input.len(), - )); + self.instructions + .push(Instruction::CallPrimitive(prim.clone(), prim.input.len())); } } @@ -321,7 +319,9 @@ impl EGraph { Instruction::CallPrimitive(p, arity) => { let new_len = stack.len() - arity; let values = &stack[new_len..]; - if let Some(value) = p.primitive.apply(values, (&p.input, &p.output), Some(self)) { + if let Some(value) = + p.primitive.apply(values, (&p.input, &p.output), Some(self)) + { stack.truncate(new_len); stack.push(value); } else { diff --git a/src/constraint.rs b/src/constraint.rs index a61c94bb..0410b3f3 100644 --- a/src/constraint.rs +++ b/src/constraint.rs @@ -108,10 +108,9 @@ impl ConstraintError { ConstraintError::ImpossibleCaseIdentified( ImpossibleConstraint::CompileTimeConstantExpected { span, sort }, ) => TypeError::CompileTimeConstantExpected(sort.clone(), span.clone()), - ConstraintError::ImpossibleCaseIdentified(ImpossibleConstraint::UnboundedFunction { - head, - span, - }) => TypeError::UnboundFunction(*head, span.clone()), + ConstraintError::ImpossibleCaseIdentified( + ImpossibleConstraint::UnboundedFunction { head, span }, + ) => TypeError::UnboundFunction(*head, span.clone()), } } } @@ -243,7 +242,7 @@ where if let Some(new_self) = new_self { *self = new_self; } - return result; + result } } @@ -732,11 +731,11 @@ fn get_literal_and_global_constraints<'a, 'b>( AtomTerm::Var(_, _) => None, // Literal to type constraint AtomTerm::Literal(_, lit) => { - let typ = crate::sort::literal_sort(&lit); + let typ = crate::sort::literal_sort(lit); Some(Constraint::Assign(arg.clone(), typ)) } AtomTerm::Global(_, v) => { - if let Some(typ) = type_info.lookup_global(&v) { + if let Some(typ) = type_info.lookup_global(v) { Some(Constraint::Assign(arg.clone(), typ.clone())) } else { panic!("All global variables should be bound before type checking") diff --git a/src/lib.rs b/src/lib.rs index 52be08d0..7250ed9b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,7 +76,12 @@ pub trait PrimitiveLike { /// Constructs a type constraint for the primitive that uses the span information /// for error localization. fn get_type_constraints(&self, span: &Span) -> Box; - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), egraph: Option<&mut EGraph>) -> Option; + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + egraph: Option<&mut EGraph>, + ) -> Option; } /// Running a schedule produces a report of the results. @@ -371,7 +376,12 @@ impl PrimitiveLike for SimplePrimitive { .collect(); SimpleTypeConstraint::new(self.name(), sorts, span.clone()).into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { (self.f)(values) } } @@ -1550,7 +1560,9 @@ mod tests { use std::sync::Arc; use crate::{ - constraint::SimpleTypeConstraint, sort::{FromSort, I64Sort, IntoSort, Sort, VecSort}, ArcSort, EGraph, PrimitiveLike, Span, Value + constraint::SimpleTypeConstraint, + sort::{FromSort, I64Sort, IntoSort, Sort, VecSort}, + ArcSort, EGraph, PrimitiveLike, Span, Value, }; struct InnerProduct { diff --git a/src/sort/fn.rs b/src/sort/fn.rs index d330f778..eca6ce9d 100644 --- a/src/sort/fn.rs +++ b/src/sort/fn.rs @@ -322,7 +322,7 @@ impl TypeConstraint for FunctionCTorTypeConstraint { ImpossibleConstraint::ArityMismatch { atom: Atom { span: self.span.clone(), - head: self.name.clone(), + head: self.name, args: arguments.to_vec(), }, expected: 1, @@ -334,7 +334,7 @@ impl TypeConstraint for FunctionCTorTypeConstraint { let this = self.clone(); let arguments = arguments.to_vec(); let argument = arguments[0].clone(); - return vec![Constraint::LazyConstraint( + vec![Constraint::LazyConstraint( arguments[0].clone(), Box::new(move |sort| { let sort = sort.clone().as_arc_any(); @@ -386,7 +386,7 @@ impl TypeConstraint for FunctionCTorTypeConstraint { Constraint::And(all_constraints) }), - )]; + )] } } diff --git a/src/sort/i64.rs b/src/sort/i64.rs index 4b5addaa..38541613 100644 --- a/src/sort/i64.rs +++ b/src/sort/i64.rs @@ -115,7 +115,12 @@ impl PrimitiveLike for CountMatches { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let string1 = Symbol::load(&self.string, &values[0]).to_string(); let string2 = Symbol::load(&self.string, &values[1]).to_string(); Some(Value::from(string1.matches(&string2).count() as i64)) diff --git a/src/sort/map.rs b/src/sort/map.rs index d0cba353..46223d72 100644 --- a/src/sort/map.rs +++ b/src/sort/map.rs @@ -237,7 +237,12 @@ impl PrimitiveLike for MapRebuild { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + egraph: Option<&mut EGraph>, + ) -> Option { let egraph = egraph.unwrap(); let maps = self.map.maps.lock().unwrap(); let map = maps.get_index(values[0].bits as usize).unwrap(); @@ -272,7 +277,12 @@ impl PrimitiveLike for TermOrderingMin { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { assert_eq!(values.len(), 2); if values[0] < values[1] { Some(values[0]) @@ -295,7 +305,12 @@ impl PrimitiveLike for TermOrderingMax { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { assert_eq!(values.len(), 2); if values[0] > values[1] { Some(values[0]) @@ -314,7 +329,12 @@ impl PrimitiveLike for Ctor { SimpleTypeConstraint::new(self.name(), vec![self.map.clone()], span.clone()).into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { assert!(values.is_empty()); ValueMap::default().store(&self.map) } @@ -344,7 +364,12 @@ impl PrimitiveLike for Insert { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut map = ValueMap::load(&self.map, &values[0]); map.insert(values[1], values[2]); map.store(&self.map) @@ -370,7 +395,12 @@ impl PrimitiveLike for Get { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let map = ValueMap::load(&self.map, &values[0]); map.get(&values[1]).copied() } @@ -395,7 +425,12 @@ impl PrimitiveLike for NotContains { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let map = ValueMap::load(&self.map, &values[0]); if map.contains_key(&values[1]) { None @@ -424,7 +459,12 @@ impl PrimitiveLike for Contains { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let map = ValueMap::load(&self.map, &values[0]); if map.contains_key(&values[1]) { Some(Value::unit()) @@ -453,7 +493,12 @@ impl PrimitiveLike for Remove { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut map = ValueMap::load(&self.map, &values[0]); map.remove(&values[1]); map.store(&self.map) @@ -479,7 +524,12 @@ impl PrimitiveLike for Length { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let map = ValueMap::load(&self.map, &values[0]); Some(Value::from(map.len() as i64)) } diff --git a/src/sort/mod.rs b/src/sort/mod.rs index 7a12608a..2e611f4c 100644 --- a/src/sort/mod.rs +++ b/src/sort/mod.rs @@ -187,7 +187,12 @@ impl PrimitiveLike for ValueEq { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { assert_eq!(values.len(), 2); if values[0] == values[1] { Some(Value::unit()) diff --git a/src/sort/set.rs b/src/sort/set.rs index 70e0dfe3..48444e82 100644 --- a/src/sort/set.rs +++ b/src/sort/set.rs @@ -238,7 +238,12 @@ impl PrimitiveLike for SetOf { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let set = ValueSet::from_iter(values.iter().copied()); Some(set.store(&self.set).unwrap()) } @@ -258,7 +263,12 @@ impl PrimitiveLike for Ctor { SimpleTypeConstraint::new(self.name(), vec![self.set.clone()], span.clone()).into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { assert!(values.is_empty()); ValueSet::default().store(&self.set) } @@ -283,7 +293,12 @@ impl PrimitiveLike for SetRebuild { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + egraph: Option<&mut EGraph>, + ) -> Option { let egraph = egraph.unwrap(); let set = ValueSet::load(&self.set, &values[0]); let new_set: ValueSet = set.iter().map(|e| egraph.find(*e)).collect(); @@ -312,7 +327,12 @@ impl PrimitiveLike for Insert { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut set = ValueSet::load(&self.set, &values[0]); set.insert(values[1]); set.store(&self.set) @@ -338,7 +358,12 @@ impl PrimitiveLike for NotContains { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let set = ValueSet::load(&self.set, &values[0]); if set.contains(&values[1]) { None @@ -367,7 +392,12 @@ impl PrimitiveLike for Contains { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let set = ValueSet::load(&self.set, &values[0]); if set.contains(&values[1]) { Some(Value::unit()) @@ -396,7 +426,12 @@ impl PrimitiveLike for Union { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut set1 = ValueSet::load(&self.set, &values[0]); let set2 = ValueSet::load(&self.set, &values[1]); set1.extend(set2.iter()); @@ -423,7 +458,12 @@ impl PrimitiveLike for Intersect { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut set1 = ValueSet::load(&self.set, &values[0]); let set2 = ValueSet::load(&self.set, &values[1]); set1.retain(|k| set2.contains(k)); @@ -451,7 +491,12 @@ impl PrimitiveLike for Length { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let set = ValueSet::load(&self.set, &values[0]); Some(Value::from(set.len() as i64)) } @@ -476,7 +521,12 @@ impl PrimitiveLike for Get { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let set = ValueSet::load(&self.set, &values[0]); let index = i64::load(&I64Sort, &values[1]); set.iter().nth(index as usize).copied() @@ -502,7 +552,12 @@ impl PrimitiveLike for Remove { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut set = ValueSet::load(&self.set, &values[0]); set.remove(&values[1]); set.store(&self.set) @@ -528,7 +583,12 @@ impl PrimitiveLike for Diff { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut set1 = ValueSet::load(&self.set, &values[0]); let set2 = ValueSet::load(&self.set, &values[1]); set1.retain(|k| !set2.contains(k)); diff --git a/src/sort/string.rs b/src/sort/string.rs index 31ef0051..b453e689 100644 --- a/src/sort/string.rs +++ b/src/sort/string.rs @@ -76,7 +76,12 @@ impl PrimitiveLike for Add { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut res_string: String = "".to_owned(); for value in values { let sym = Symbol::load(&self.string, value); @@ -104,7 +109,12 @@ impl PrimitiveLike for Replace { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let string1 = Symbol::load(&self.string, &values[0]).to_string(); let string2 = Symbol::load(&self.string, &values[1]).to_string(); let string3 = Symbol::load(&self.string, &values[2]).to_string(); diff --git a/src/sort/unit.rs b/src/sort/unit.rs index 37ac31e4..436f2bd6 100644 --- a/src/sort/unit.rs +++ b/src/sort/unit.rs @@ -51,7 +51,12 @@ impl PrimitiveLike for NotEqualPrimitive { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { (values[0] != values[1]).then(Value::unit) } } diff --git a/src/sort/vec.rs b/src/sort/vec.rs index b8939456..56d53c30 100644 --- a/src/sort/vec.rs +++ b/src/sort/vec.rs @@ -247,7 +247,12 @@ impl PrimitiveLike for VecRebuild { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + egraph: Option<&mut EGraph>, + ) -> Option { let egraph = egraph.unwrap(); let vec = ValueVec::load(&self.vec, &values[0]); let new_vec: ValueVec = vec.iter().map(|e| egraph.find(*e)).collect(); @@ -272,7 +277,12 @@ impl PrimitiveLike for VecOf { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let vec = ValueVec::from_iter(values.iter().copied()); vec.store(&self.vec) } @@ -294,7 +304,12 @@ impl PrimitiveLike for Append { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let vec = ValueVec::from_iter(values.iter().flat_map(|v| ValueVec::load(&self.vec, v))); vec.store(&self.vec) } @@ -314,7 +329,12 @@ impl PrimitiveLike for Ctor { SimpleTypeConstraint::new(self.name(), vec![self.vec.clone()], span.clone()).into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { assert!(values.is_empty()); ValueVec::default().store(&self.vec) } @@ -339,7 +359,12 @@ impl PrimitiveLike for Push { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut vec = ValueVec::load(&self.vec, &values[0]); vec.push(values[1]); vec.store(&self.vec) @@ -365,7 +390,12 @@ impl PrimitiveLike for Pop { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut vec = ValueVec::load(&self.vec, &values[0]); vec.pop(); vec.store(&self.vec) @@ -391,7 +421,12 @@ impl PrimitiveLike for NotContains { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let vec = ValueVec::load(&self.vec, &values[0]); if vec.contains(&values[1]) { None @@ -420,7 +455,12 @@ impl PrimitiveLike for Contains { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let vec = ValueVec::load(&self.vec, &values[0]); if vec.contains(&values[1]) { Some(Value::unit()) @@ -449,7 +489,12 @@ impl PrimitiveLike for Length { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let vec = ValueVec::load(&self.vec, &values[0]); Some(Value::from(vec.len() as i64)) } @@ -474,7 +519,12 @@ impl PrimitiveLike for Get { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let vec = ValueVec::load(&self.vec, &values[0]); let index = i64::load(&I64Sort, &values[1]); vec.get(index as usize).copied() @@ -505,7 +555,12 @@ impl PrimitiveLike for Set { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut vec = ValueVec::load(&self.vec, &values[0]); let index = i64::load(&I64Sort, &values[1]); vec[index as usize] = values[2]; @@ -532,7 +587,12 @@ impl PrimitiveLike for Remove { .into_box() } - fn apply(&self, values: &[Value], _sorts: (&[ArcSort], &ArcSort), _egraph: Option<&mut EGraph>) -> Option { + fn apply( + &self, + values: &[Value], + _sorts: (&[ArcSort], &ArcSort), + _egraph: Option<&mut EGraph>, + ) -> Option { let mut vec = ValueVec::load(&self.vec, &values[0]); let i = i64::load(&I64Sort, &values[1]); vec.remove(i.try_into().unwrap());