1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30:03 -04:00

Increase MSRV to 1.67 (#3234)

* Bump MSRV to 1.67

* clippy fixes

* cargo clippy: inline format args

* Add `clippy::uninlined_format_args` to cranky lints

* Fix clippy on wasm

* More clippy fixes
This commit is contained in:
Emil Ernerfeldt
2023-08-11 13:54:02 +02:00
committed by GitHub
parent bdeae9e959
commit 08fb447fb5
84 changed files with 166 additions and 193 deletions

View File

@@ -183,9 +183,7 @@ where
/// Round a value to the given number of decimal places.
pub fn round_to_decimals(value: f64, decimal_places: usize) -> f64 {
// This is a stupid way of doing this, but stupid works.
format!("{:.*}", decimal_places, value)
.parse()
.unwrap_or(value)
format!("{value:.decimal_places$}").parse().unwrap_or(value)
}
pub fn format_with_minimum_decimals(value: f64, decimals: usize) -> String {
@@ -203,7 +201,7 @@ pub fn format_with_decimals_in_range(value: f64, decimal_range: RangeInclusive<u
if min_decimals != max_decimals {
// Ugly/slow way of doing this. TODO(emilk): clean up precision.
for decimals in min_decimals..max_decimals {
let text = format!("{:.*}", decimals, value);
let text = format!("{value:.decimals$}");
let epsilon = 16.0 * f32::EPSILON; // margin large enough to handle most peoples round-tripping needs
if almost_equal(text.parse::<f32>().unwrap(), value as f32, epsilon) {
// Enough precision to show the value accurately - good!
@@ -214,7 +212,7 @@ pub fn format_with_decimals_in_range(value: f64, decimal_range: RangeInclusive<u
// Probably the value was set not by the slider, but from outside.
// In any case: show the full value
}
format!("{:.*}", max_decimals, value)
format!("{value:.max_decimals$}")
}
/// Return true when arguments are the same within some rounding error.

View File

@@ -206,7 +206,7 @@ impl std::ops::Index<usize> for Pos2 {
match index {
0 => &self.x,
1 => &self.y,
_ => panic!("Pos2 index out of bounds: {}", index),
_ => panic!("Pos2 index out of bounds: {index}"),
}
}
}
@@ -217,7 +217,7 @@ impl std::ops::IndexMut<usize> for Pos2 {
match index {
0 => &mut self.x,
1 => &mut self.y,
_ => panic!("Pos2 index out of bounds: {}", index),
_ => panic!("Pos2 index out of bounds: {index}"),
}
}
}

View File

@@ -184,10 +184,7 @@ mod test {
let expected = vec2(0.0, 3.0);
assert!(
(rotated - expected).length() < 1e-5,
"Expected {:?} to equal {:?}. rot: {:?}",
rotated,
expected,
rot,
"Expected {rotated:?} to equal {expected:?}. rot: {rot:?}",
);
let undone = rot.inverse() * rot;

View File

@@ -292,7 +292,7 @@ impl std::ops::Index<usize> for Vec2 {
match index {
0 => &self.x,
1 => &self.y,
_ => panic!("Vec2 index out of bounds: {}", index),
_ => panic!("Vec2 index out of bounds: {index}"),
}
}
}
@@ -303,7 +303,7 @@ impl std::ops::IndexMut<usize> for Vec2 {
match index {
0 => &mut self.x,
1 => &mut self.y,
_ => panic!("Vec2 index out of bounds: {}", index),
_ => panic!("Vec2 index out of bounds: {index}"),
}
}
}