Clippy lint fixes

This commit is contained in:
Magnus Ulimoen 2023-01-18 19:05:41 +01:00
parent 4c5c0305e4
commit 909e15572e
6 changed files with 17 additions and 18 deletions

View File

@ -748,11 +748,11 @@ impl std::fmt::Debug for BoundaryCharacteristic {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::This => write!(f, "This"),
Self::Grid(g) => write!(f, "Grid({})", g),
Self::Vortex(vp) => write!(f, "{:?}", vp),
Self::Grid(g) => write!(f, "Grid({g})"),
Self::Vortex(vp) => write!(f, "{vp:?}"),
Self::Eval(_) => write!(f, "Eval"),
Self::Interpolate(_, _) => write!(f, "Interpolate"),
Self::MultiGrid(m) => write!(f, "Multigrid: {:?}", m),
Self::MultiGrid(m) => write!(f, "Multigrid: {m:?}"),
}
}
}

View File

@ -117,10 +117,10 @@ pub enum InterpolationOperator {
NineH2,
}
impl Into<Box<dyn sbp::operators::InterpolationOperator>> for InterpolationOperator {
fn into(self) -> Box<dyn sbp::operators::InterpolationOperator> {
impl From<InterpolationOperator> for Box<dyn sbp::operators::InterpolationOperator> {
fn from(val: InterpolationOperator) -> Self {
use sbp::operators::{Interpolation4, Interpolation8, Interpolation9, Interpolation9h2};
match self {
match val {
InterpolationOperator::Four => Box::new(Interpolation4),
InterpolationOperator::Eight => Box::new(Interpolation8),
InterpolationOperator::Nine => Box::new(Interpolation9),

View File

@ -56,13 +56,13 @@ fn main() {
let config: input::Configuration = match json5::from_str(&filecontents) {
Ok(config) => config,
Err(e) => {
eprintln!("Configuration could not be read: {}", e);
eprintln!("Configuration could not be read: {e}");
if let json5::Error::Message {
location: Some(location),
..
} = e
{
eprintln!("\t{:?}", location);
eprintln!("\t{location:?}");
}
return;
}
@ -157,7 +157,7 @@ fn main() {
println!("Time elapsed: {} seconds", duration.as_secs_f64());
}
if let Some(error) = outinfo.error {
println!("Total error: {:e}", error);
println!("Total error: {error:e}");
}
}
}

View File

@ -139,12 +139,12 @@ impl input::Configuration {
let xi = operators.xi.unwrap_or_else(|| {
default_operators
.xi
.unwrap_or_else(|| panic!("No xi operator found for grid: {}", name))
.unwrap_or_else(|| panic!("No xi operator found for grid: {name}"))
});
let eta = operators.eta.unwrap_or_else(|| {
default_operators
.eta
.unwrap_or_else(|| panic!("No eta operator found for grid: {}", name))
.unwrap_or_else(|| panic!("No eta operator found for grid: {name}"))
});
use input::Operator as op;
@ -183,9 +183,8 @@ impl input::Configuration {
BoundaryConditions::Expressions(expr) => {
euler::BoundaryCharacteristic::Eval(expr.clone() )
}
_ => panic!(
"Boundary conditions are not available, but needed for grid {}",
name
BoundaryConditions::NotNeeded => panic!(
"Boundary conditions are not available, but needed for grid {name}"
),
},
Some(BoundaryType::This) => euler::BoundaryCharacteristic::This,
@ -193,7 +192,7 @@ impl input::Configuration {
if let BoundaryConditions::Vortex(vortex) = &boundary_conditions {
vortex.clone()
} else {
panic!("Wanted vortex boundary conditions not found, needed for grid {}", name)
panic!("Wanted vortex boundary conditions not found, needed for grid {name}")
},
),
Some(BoundaryType::Neighbour(name)) => {

View File

@ -200,7 +200,7 @@ impl BaseSystem {
.zip(push)
.enumerate()
{
let builder = std::thread::Builder::new().name(format!("mg: {}", name));
let builder = std::thread::Builder::new().name(format!("mg: {name}"));
let boundary_conditions = bt.map(|bt| match bt {
euler::BoundaryCharacteristic::This => DistributedBoundaryConditions::This,
@ -444,7 +444,7 @@ impl System {
for _ in 0..sys.sys.len() {
e += match sys.recv.recv().unwrap() {
(_, MsgToHost::Error(e)) => e,
(_, m) => panic!("Unexpected message: {:?}", m),
(_, m) => panic!("Unexpected message: {m:?}"),
}
}
e

View File

@ -258,7 +258,7 @@ mod approx {
fn default_epsilon() -> Self::Epsilon {
T::default_epsilon()
}
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
fn abs_diff_eq(&self, other: &Self, _epsilon: Self::Epsilon) -> bool {
self.iter()
.zip(other.iter())
.all(|(r, l)| r.abs_diff_eq(l, T::default_epsilon()))