Skip to content

Commit 408d2a8

Browse files
committed
Cargo clippy
1 parent 8cb5c16 commit 408d2a8

File tree

6 files changed

+20
-31
lines changed

6 files changed

+20
-31
lines changed

examples/lookup.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() {
88
let indices = icosphere.get_all_indices();
99
let vertices = icosphere.raw_points();
1010

11-
println!("Indices: {:?}", indices);
11+
println!("Indices: {indices:?}");
1212

1313
println!("\nVertices:");
1414
for (i, vertex) in vertices.iter().enumerate() {
@@ -33,7 +33,7 @@ fn main() {
3333
let mut ab = AdjacencyBuilder::new(vertices.len());
3434
ab.add_indices(&indices);
3535
let adjency = ab.finish();
36-
println!("\nVertex neighborlist:\n(The result preserves winding: the resulting array is wound around the center vertex in the same way that the source triangles were wound.):\n {:?}", adjency);
36+
println!("\nVertex neighborlist:\n(The result preserves winding: the resulting array is wound around the center vertex in the same way that the source triangles were wound.):\n {adjency:?}");
3737

3838
let face_area = |a: usize, b: usize, c: usize| {
3939
let a = vertices[a];
@@ -68,5 +68,5 @@ fn main() {
6868
writeln!(weight_file, "{weight}").expect("Failed to write to file");
6969
}
7070

71-
println!("\nVertex weights:\n {:?}", weights);
71+
println!("\nVertex weights:\n {weights:?}");
7272
}

src/energy.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ impl PairMatrix {
6161

6262
if use_polarization {
6363
log::debug!(
64-
"Adding ion-induced dipole term for atom pair ({}, {}). Alphas: {}, {}",
65-
i,
66-
j,
67-
alpha1,
68-
alpha2
64+
"Adding ion-induced dipole term for atom pair ({i}, {j}). Alphas: {alpha1}, {alpha2}"
6965
);
7066
}
7167
let coulomb =
@@ -99,7 +95,7 @@ impl PairMatrix {
9995
energy += potentials[(a, b)].isotropic_twobody_energy(distance_sq);
10096
}
10197
}
102-
trace!("molecule-molecule energy: {:.2} kJ/mol", energy);
98+
trace!("molecule-molecule energy: {energy:.2} kJ/mol");
10399
energy
104100
}
105101
}

src/icoscan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub fn do_icoscan(
146146
.map(|&p| [p.x as f32, p.y as f32, p.z as f32])
147147
.collect();
148148
traj.write(&frame).expect("Failed to write XTC frame");
149-
writeln!(energy_file, "{:.6}", data).expect("Failed to write energy to file");
149+
writeln!(energy_file, "{data:.6}").expect("Failed to write energy to file");
150150
};
151151

152152
r_and_omega
@@ -163,7 +163,7 @@ pub fn do_icoscan(
163163
write_frame(&oriented_a, &oriented_b, _data_b.get().unwrap());
164164
});
165165
});
166-
info!("Wrote {} frames to trajectory file", frame_cnt);
166+
info!("Wrote {frame_cnt} frames to trajectory file");
167167
}
168168

169169
// Partition function contribution for single (r, omega) point

src/icotable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ impl Table6D {
409409

410410
// We have a new angular resolution, depending on number of subdivisions
411411
let angle_resolution = table_b.angle_resolution();
412-
log::info!("Actual angle resolution = {:.2} radians", angle_resolution);
412+
log::info!("Actual angle resolution = {angle_resolution:.2} radians");
413413

414414
let table_a = IcoTable4D::from_vertices(vertices, Some(table_b)); // A: 𝜃 and 𝜑
415415
let table_omega = PaddedTable::<IcoTable4D>::new(0.0, 2.0 * PI, angle_resolution, table_a); // 𝜔
@@ -459,14 +459,14 @@ pub(crate) fn vmd_draw(
459459
scale: Option<f32>,
460460
) -> Result<()> {
461461
let num_faces = icosphere.get_all_indices().len() / 3;
462-
let path = path.with_extension(format!("faces{}.vmd", num_faces));
462+
let path = path.with_extension(format!("faces{num_faces}.vmd"));
463463
let mut stream = std::fs::File::create(path)?;
464464
icosphere.get_all_indices().chunks(3).try_for_each(|c| {
465465
let scale = scale.unwrap_or(1.0);
466466
let a = icosphere.raw_points()[c[0] as usize] * scale;
467467
let b = icosphere.raw_points()[c[1] as usize] * scale;
468468
let c = icosphere.raw_points()[c[2] as usize] * scale;
469-
writeln!(stream, "draw color {}", color)?;
469+
writeln!(stream, "draw color {color}")?;
470470
writeln!(
471471
stream,
472472
"draw triangle {{{:.3} {:.3} {:.3}}} {{{:.3} {:.3} {:.3}}} {{{:.3} {:.3} {:.3}}}",

src/main.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn do_scan(cmd: &Commands) -> Result<()> {
187187
.to_xyz(&mut File::create("confout.xyz")?, topology.atomkinds())?;
188188
}
189189

190-
info!("{}", medium);
190+
info!("{medium}");
191191
info!(
192192
"Molecular net-charges: [{:.2}e, {:.2}e]",
193193
ref_a.net_charge(),
@@ -208,8 +208,7 @@ fn do_scan(cmd: &Commands) -> Result<()> {
208208
);
209209

210210
info!(
211-
"COM range: [{:.1}, {:.1}) in {:.1} Å steps 🐾",
212-
rmin, rmax, dr
211+
"COM range: [{rmin:.1}, {rmax:.1}) in {dr:.1} Å steps 🐾"
213212
);
214213
icoscan::do_icoscan(
215214
*rmin,
@@ -352,7 +351,7 @@ fn do_potential(cmd: &Commands) -> Result<()> {
352351
energy::electric_potential(&structure, &v.scale(*radius), &multipole)
353352
})?;
354353

355-
File::create("pot_at_vertices.dat")?.write_fmt(format_args!("{}", icotable))?;
354+
File::create("pot_at_vertices.dat")?.write_fmt(format_args!("{icotable}"))?;
356355

357356
// Make PQR file illustrating the electric potential at each vertex
358357
let mut pqr_file = File::create("potential.pqr")?;
@@ -374,21 +373,15 @@ fn do_potential(cmd: &Commands) -> Result<()> {
374373
let abs_err = (interpolated - exact).abs();
375374
if abs_err > 0.05 {
376375
log::debug!(
377-
"Potential at theta={:.3} phi={:.3} is {:.4} (exact: {:.4}) abs. error {:.4}",
378-
theta,
379-
phi,
380-
interpolated,
381-
exact,
382-
abs_err
376+
"Potential at theta={theta:.3} phi={phi:.3} is {interpolated:.4} (exact: {exact:.4}) abs. error {abs_err:.4}"
383377
);
384378
let face = icotable.nearest_face(&point);
385379
let bary = icotable.naive_barycentric(&point, &face);
386-
log::debug!("Face: {:?} Barycentric: {:?}\n", face, bary);
380+
log::debug!("Face: {face:?} Barycentric: {bary:?}\n");
387381
}
388382
writeln!(
389383
pot_angles_file,
390-
"{:.3} {:.3} {:.4} {:.4} {:.4}",
391-
theta, phi, interpolated, exact, rel_err
384+
"{theta:.3} {phi:.3} {interpolated:.4} {exact:.4} {rel_err:.4}"
392385
)?;
393386
}
394387
}

src/structure.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Structure {
5353
atomkinds
5454
.find_name(name)
5555
.map(|kind| kind.id())
56-
.context(format!("Unknown atom name in structure file: {:?}", name))
56+
.context(format!("Unknown atom name in structure file: {name:?}"))
5757
})
5858
.try_collect()?;
5959

@@ -63,7 +63,7 @@ impl Structure {
6363
atomkinds
6464
.find_name(name)
6565
.map(|kind| kind.mass())
66-
.context(format!("Unknown atom name in XYZ file: {}", name))
66+
.context(format!("Unknown atom name in XYZ file: {name}"))
6767
})
6868
.try_collect()?;
6969

@@ -73,7 +73,7 @@ impl Structure {
7373
atomkinds
7474
.find_name(name)
7575
.map(|i| i.charge())
76-
.context(format!("Unknown atom name in XYZ file: {}", name))
76+
.context(format!("Unknown atom name in XYZ file: {name}"))
7777
})
7878
.try_collect()?;
7979

@@ -83,7 +83,7 @@ impl Structure {
8383
atomkinds
8484
.find_name(name)
8585
.map(|i| i.sigma().unwrap_or(0.0) * 0.5)
86-
.context(format!("Unknown atom name in XYZ file: {}", name))
86+
.context(format!("Unknown atom name in XYZ file: {name}"))
8787
})
8888
.try_collect()?;
8989
let mut structure = Self {

0 commit comments

Comments
 (0)