Skip to content

Commit

Permalink
Fail to implement MulDivAssign with Ratio on RHS
Browse files Browse the repository at this point in the history
  • Loading branch information
jacg committed Aug 18, 2022
1 parent 498ad3c commit 3805b37
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,21 @@ macro_rules! system {
}
}

impl<D, Ul, Ur, V> $crate::lib::ops::$MulDivAssignTrait<Quantity<DimensionOne, Ur, V>> for Quantity<D, Ul, V>
where
D: Dimension + ?Sized,
D::Kind: $crate::marker::$MulDivAssignTrait,
Ul: Units<V> + ?Sized,
Ur: Units<V> + ?Sized,
V: $crate::num::Num + $crate::Conversion<V>
+ $crate::lib::ops::$MulDivAssignTrait<Quantity<DimensionOne, Ur, V>>,
{
#[inline(always)]
fn $muldivassign_fun(&mut self, rhs: Quantity<DimensionOne, Ur, V>) {
self.value $muldivassign_op rhs;
}
}

#[doc(hidden)]
mod $Mod {
storage_types! {
Expand Down
8 changes: 4 additions & 4 deletions src/tests/impl_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ mod vv {
test!(div_ratio_right m(6.) / ratio(2.), m(3.)); // 6 c.f. BBB below
test!(mul_ratio_right_p m(4.) * pct(50.), m(2.)); // 6 c.f. CCC below
test!(div_ratio_right_p m(4.) / pct(50.), m(8.)); // 6 c.f. DDD below
// test!(mul_assign_ratio [ m(4.) ] *= ratio(2.), m(8.)); // ERR c.f. AAA above
// test!(div_assign_ratio [ m(6.) ] /= ratio(2.), m(3.)); // ERR c.f. BBB above
// test!(mul_assign_ratio_p [ m(4.) ] *= pct(50.), m(4.)); // ERR c.f. CCC above
// test!(div_assign_ratio_p [ m(4.) ] /= pct(50.), m(8.)); // ERR c.f. DDD above
test!(mul_assign_ratio [ m(4.) ] *= ratio(2.), m(8.)); // ERR c.f. AAA above
test!(div_assign_ratio [ m(6.) ] /= ratio(2.), m(3.)); // ERR c.f. BBB above
test!(mul_assign_ratio_p [ m(4.) ] *= pct(50.), m(4.)); // ERR c.f. CCC above
test!(div_assign_ratio_p [ m(4.) ] /= pct(50.), m(8.)); // ERR c.f. DDD above
test!(mul_bare_right m(4.) * 2. , m(8.)); // 7
test!(div_bare_right m(6.) / 2. , m(3.)); // 7
test!(mul_assign_bare [ m(2.) ] *= 3. , m(6.)); // 8
Expand Down

0 comments on commit 3805b37

Please sign in to comment.