Skip to content

Commit

Permalink
fix(style): use {f32,usize}::midpoint when appropriate
Browse files Browse the repository at this point in the history
style: use `f32::midpoint()`
  • Loading branch information
samueltardieu committed Jan 6, 2025
1 parent 9d88d1a commit 5124e84
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ impl<C> Matrix<C> {
2 => self.data.reverse(),
n => {
for r in 0..self.rows / 2 {
for c in 0..(self.columns + 1) / 2 {
for c in 0..usize::midpoint(1, self.columns) {
// i1 … i2
// … … …
// i4 … i3
Expand Down
2 changes: 1 addition & 1 deletion tests/gps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Coords {
#[expect(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
fn distance_in_meters(&self, other: &Self) -> u64 {
let x =
(other.lon_rad() - self.lon_rad()) * ((other.lat_rad() + self.lat_rad()) / 2.0).cos();
(other.lon_rad() - self.lon_rad()) * f32::midpoint(other.lat_rad(), self.lat_rad()).cos();
let y = other.lat_rad() - self.lat_rad();
(x.hypot(y) * 6_371_000.0).round() as u64
}
Expand Down

0 comments on commit 5124e84

Please sign in to comment.