File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -371,7 +371,6 @@ impl<G: PrimeGroup> TryFrom<&LinearRelation<G>> for CanonicalLinearRelation<G> {
371371
372372 // Process each constraint using the modular helper method
373373 for ( lhs, rhs) in iter:: zip ( & relation. image , & relation. linear_map . linear_combinations ) {
374-
375374 let lhs_value = relation
376375 . linear_map
377376 . group_elements
@@ -384,7 +383,6 @@ impl<G: PrimeGroup> TryFrom<&LinearRelation<G>> for CanonicalLinearRelation<G> {
384383 . iter ( )
385384 . all ( |weighted| matches ! ( weighted. term. scalar, ScalarTerm :: Unit ) )
386385 {
387-
388386 let rhs_value = rhs. 0 . iter ( ) . fold ( G :: identity ( ) , |acc, weighted| {
389387 acc + relation
390388 . linear_map
Original file line number Diff line number Diff line change @@ -552,13 +552,13 @@ mod sub {
552552 impl <G , Rhs > Sub <Rhs > for $type
553553 where
554554 Rhs : Neg ,
555- < Rhs as Neg >:: Output : Add < Self >,
555+ Self : Add << Rhs as Neg >:: Output >,
556556 {
557- type Output = << Rhs as Neg >:: Output as Add < Self >>:: Output ;
557+ type Output = <Self as Add << Rhs as Neg >:: Output >>:: Output ;
558558
559559 #[ allow( clippy:: suspicious_arithmetic_impl) ]
560560 fn sub( self , rhs: Rhs ) -> Self :: Output {
561- rhs. neg( ) + self
561+ self + rhs. neg( )
562562 }
563563 }
564564 ) +
@@ -790,6 +790,18 @@ mod tests {
790790 assert_eq ! ( diff. terms( ) [ 1 ] . weight, Scalar :: ONE ) ;
791791 }
792792
793+ #[ test]
794+ fn test_scalar_var_subtraction_by_scalar ( ) {
795+ let x = scalar_var ( 0 ) ;
796+
797+ let diff = x - Scalar :: ONE ;
798+ assert_eq ! ( diff. terms( ) . len( ) , 2 ) ;
799+ assert_eq ! ( diff. terms( ) [ 0 ] . term, ScalarTerm :: Var ( x) ) ;
800+ assert_eq ! ( diff. terms( ) [ 0 ] . weight, Scalar :: ONE ) ;
801+ assert_eq ! ( diff. terms( ) [ 1 ] . term, ScalarTerm :: Unit ) ;
802+ assert_eq ! ( diff. terms( ) [ 1 ] . weight, -Scalar :: ONE ) ;
803+ }
804+
793805 #[ test]
794806 fn test_group_var_subtraction ( ) {
795807 let g = group_var ( 0 ) ;
You can’t perform that action at this time.
0 commit comments