Skip to content

Commit

Permalink
Remove unnecessary qualifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
iliekturtles committed Jun 24, 2023
1 parent 071b6d9 commit fcfdf12
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
30 changes: 15 additions & 15 deletions src/tests/quantity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ storage_types! {
quickcheck! {
#[allow(trivial_casts)]
fn add(l: A<V>, r: A<V>) -> TestResult {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let f = (&*l + &*r) / &km;
let i = (&*l / &km) + (&*r / &km);

Expand All @@ -71,7 +71,7 @@ storage_types! {

#[allow(trivial_casts)]
fn sub(l: A<V>, r: A<V>) -> TestResult {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let f = (&*l - &*r) / &km;
let i = (&*l / &km) - (&*r / &km);

Expand All @@ -87,7 +87,7 @@ storage_types! {

#[allow(trivial_casts)]
fn mul_quantity(l: A<V>, r: A<V>) -> TestResult {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();

TestResult::from_bool(
Test::approx_eq(&/*Area::new::<square_meter>*/(&*l * &*r),
Expand All @@ -111,7 +111,7 @@ storage_types! {
return TestResult::discard();
}

let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();

TestResult::from_bool(
Test::approx_eq(&/*Ratio::new::<ratio>*/(&*l / &*r),
Expand All @@ -134,7 +134,7 @@ storage_types! {
return TestResult::discard();
}

let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let f = (&*l % &*r) / &km;
let i = (&*l / &km) % (&*r / &km);

Expand All @@ -150,7 +150,7 @@ storage_types! {

#[allow(trivial_casts)]
fn eq(l: A<V>, r: A<V>) -> bool {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let a = *l == ((*r).clone() / &km) * &km;
let b = (*l).clone() / &km == (*r).clone() / &km;
let x = f::Length::new::<meter>((*l).clone())
Expand All @@ -163,7 +163,7 @@ storage_types! {

#[allow(trivial_casts)]
fn ne(l: A<V>, r: A<V>) -> bool {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let a = *l != ((*r).clone() / &km) * &km;
let b = (*l).clone() / &km != (*r).clone() / &km;
let x = f::Length::new::<meter>((*l).clone())
Expand Down Expand Up @@ -295,7 +295,7 @@ mod non_big {
quickcheck! {
#[allow(trivial_casts)]
fn add_assign(l: A<V>, r: A<V>) -> TestResult {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let mut f = *l;
let mut i = *l / &km;
let mut v = k::Length::new::<meter>(*l);
Expand All @@ -313,7 +313,7 @@ mod non_big {

#[allow(trivial_casts)]
fn sub_assign(l: A<V>, r: A<V>) -> TestResult {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let mut f = *l;
let mut i = *l / &km;
let mut v = k::Length::new::<meter>(*l);
Expand All @@ -335,7 +335,7 @@ mod non_big {
return TestResult::discard();
}

let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let mut f = *l;
let mut i = *l / &km;
let mut v = k::Length::new::<meter>(*l);
Expand Down Expand Up @@ -506,7 +506,7 @@ mod non_complex {
quickcheck! {
#[allow(trivial_casts)]
fn partial_cmp(l: A<V>, r: A<V>) -> bool {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let a = (*l).partial_cmp(&(((*r).clone() / &km) * &km));
let b = ((*l).clone() / &km).partial_cmp(&((*r).clone() / &km));
let x = f::Length::new::<meter>((*l).clone()).partial_cmp(
Expand All @@ -519,7 +519,7 @@ mod non_complex {

#[allow(trivial_casts)]
fn lt(l: A<V>, r: A<V>) -> bool {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let a = (*l).lt(&(((*r).clone() / &km) * &km));
let b = ((*l).clone() / &km).lt(&((*r).clone() / &km));
let x = f::Length::new::<meter>((*l).clone()).lt(
Expand All @@ -532,7 +532,7 @@ mod non_complex {

#[allow(trivial_casts)]
fn le(l: A<V>, r: A<V>) -> bool {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let a = (*l).le(&(((*r).clone() / &km) * &km));
let b = ((*l).clone() / &km).le(&((*r).clone() / &km));
let x = f::Length::new::<meter>((*l).clone()).le(
Expand All @@ -545,7 +545,7 @@ mod non_complex {

#[allow(trivial_casts)]
fn gt(l: A<V>, r: A<V>) -> bool {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let a = (*l).gt(&(((*r).clone() / &km) * &km));
let b = ((*l).clone() / &km).gt(&((*r).clone() / &km));
let x = f::Length::new::<meter>((*l).clone()).gt(
Expand All @@ -558,7 +558,7 @@ mod non_complex {

#[allow(trivial_casts)]
fn ge(l: A<V>, r: A<V>) -> bool {
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let a = (*l).ge(&(((*r).clone() / &km) * &km));
let b = ((*l).clone() / &km).ge(&((*r).clone() / &km));
let x = f::Length::new::<meter>((*l).clone()).ge(
Expand Down
16 changes: 7 additions & 9 deletions src/tests/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ storage_types! {
#[allow(trivial_casts)]
fn from_base(v: A<V>) -> bool
{
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let f_coefficient: V =
<degree_fahrenheit as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let f_coefficient: V = <degree_fahrenheit as Conversion<V>>::coefficient().value();
let f_constant: V =
<degree_fahrenheit as crate::Conversion<V>>::constant(ConstantOp::Add).value();
<degree_fahrenheit as Conversion<V>>::constant(ConstantOp::Add).value();

// meter -> meter.
Test::approx_eq(&*v,
Expand Down Expand Up @@ -64,11 +63,10 @@ storage_types! {
#[allow(trivial_casts)]
fn to_base(v: A<V>) -> bool
{
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let f_coefficient: V =
<degree_fahrenheit as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let f_coefficient: V = <degree_fahrenheit as Conversion<V>>::coefficient().value();
let f_constant: V =
<degree_fahrenheit as crate::Conversion<V>>::constant(ConstantOp::Add).value();
<degree_fahrenheit as Conversion<V>>::constant(ConstantOp::Add).value();

// meter -> meter.
Test::approx_eq(&*v,
Expand Down Expand Up @@ -105,7 +103,7 @@ storage_types! {
#[allow(trivial_casts)]
fn change_base(v: A<V>) -> TestResult
{
let km: V = <kilometer as crate::Conversion<V>>::coefficient().value();
let km: V = <kilometer as Conversion<V>>::coefficient().value();
let f1 = (*v).clone();
let i1 = &*v * &km / &km;

Expand Down

0 comments on commit fcfdf12

Please sign in to comment.