Skip to content

Commit

Permalink
Merge pull request #72 from torokati44/chores
Browse files Browse the repository at this point in the history
Fix a couple clippy lints, run cargo format
  • Loading branch information
sebcrozet authored Jan 18, 2022
2 parents 11f6fda + 81e6987 commit 1398e38
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ where
/// Replace the epsilon value with the one specified.
#[inline]
pub fn epsilon(self, epsilon: A::Epsilon) -> AbsDiff<A, B> {
AbsDiff { epsilon, ..self }
AbsDiff { epsilon }
}

/// Peform the equality comparison
Expand Down
30 changes: 13 additions & 17 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,39 +84,35 @@ macro_rules! __assert_approx {
($eq:ident, $given:expr, $expected:expr) => {{
let (given, expected) = (&($given), &($expected));

if !$eq!(*given, *expected) {
panic!(
assert!($eq!(*given, *expected),
"assert_{}!({}, {})
left = {:?}
right = {:?}
",
stringify!($eq),
stringify!($given),
stringify!($expected),
given, expected,
);
}
stringify!($eq),
stringify!($given),
stringify!($expected),
given, expected,
);
}};
($eq:ident, $given:expr, $expected:expr, $($opt:ident = $val:expr),+) => {{
let (given, expected) = (&($given), &($expected));

if !$eq!(*given, *expected, $($opt = $val),+) {
panic!(
assert!($eq!(*given, *expected, $($opt = $val),+),
"assert_{}!({}, {}, {})
left = {:?}
right = {:?}
",
stringify!($eq),
stringify!($given),
stringify!($expected),
stringify!($($opt = $val),+),
given, expected,
);
}
stringify!($eq),
stringify!($given),
stringify!($expected),
stringify!($($opt = $val),+),
given, expected,
);
}};
}

Expand Down
8 changes: 2 additions & 6 deletions src/relative_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ where
fn default_max_relative() -> Self::Epsilon;

/// A test for equality that uses a relative comparison if the values are far apart.
fn relative_eq(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool;
fn relative_eq(&self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon)
-> bool;

/// The inverse of [`RelativeEq::relative_eq`].
fn relative_ne(
Expand Down
2 changes: 1 addition & 1 deletion src/ulps_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ where
fn ulps_eq(&self, other: &[B], epsilon: A::Epsilon, max_ulps: u32) -> bool {
self.len() == other.len()
&& Iterator::zip(self.iter(), other)
.all(|(x, y)| A::ulps_eq(x, y, epsilon.clone(), max_ulps.clone()))
.all(|(x, y)| A::ulps_eq(x, y, epsilon.clone(), max_ulps))
}
}

Expand Down

0 comments on commit 1398e38

Please sign in to comment.