Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a couple clippy lints, run cargo format #72

Merged
merged 4 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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