1
Fork 0

cargo clippy fixes

This commit is contained in:
Andy Killorin 2023-11-04 20:54:50 -05:00
parent e90f9fd6b4
commit b18987a736
Signed by: ank
GPG key ID: B6241CA3B552BCA4
2 changed files with 12 additions and 13 deletions

View file

@ -1,4 +1,3 @@
use std::ops::Deref;
use std::sync::Mutex;
use constants::*;
@ -157,10 +156,10 @@ fn main() {
let mut allparts = ScadFile::new();
allparts.set_detail(50);
for (idx, part) in PARTS.lock().unwrap().to_owned().into_iter().enumerate() {
for (idx, part) in PARTS.lock().unwrap().iter().cloned().enumerate() {
allparts.add_object(scad!(Translate2d(vec2(0.0, INF * idx as f32)); part));
}
allparts.write_to_file(format!("build/allparts.scad"));
allparts.write_to_file("build/allparts.scad".to_string());
}
enum SparType {
@ -232,7 +231,7 @@ fn topspar_negative(airfoil: &SeligFile, chord: f32, range: Range<f32>) -> ScadO
let mut last: Option<ScadObject> = None;
for point in span {
let mut current = scad!(Square(vec2(0.001 / chord, CARDBOARD_WIDTH / chord)));
current = scad!(Translate2d(point.clone() - vec2(0.0, CARDBOARD_WIDTH/chord)); current);
current = scad!(Translate2d(point - vec2(0.0, CARDBOARD_WIDTH/chord)); current);
if let Some(last_mask) = last {
let mut hull = scad!(Hull);
hull.add_child(current.clone());
@ -292,7 +291,7 @@ fn wing(
let mut transform = scad!(Translate(vec3(0.0, spacing, 0.0)));
let strut = strut(&aerofoil, chord, CARDBOARD_WIDTH, &spar);
let strut = strut(aerofoil, chord, CARDBOARD_WIDTH, &spar);
transform.add_child(strut);
wing.add_child(transform);
}
@ -320,7 +319,7 @@ fn topwing_spar(
let spacing = strut_idx as f32 * gap;
let shape = topspar_negative(&aerofoil, chord, 0.1..0.6);
let shape = topspar_negative(aerofoil, chord, 0.1..0.6);
let extruded = extrude_strut(shape.clone(), scad!(Union), CARDBOARD_WIDTH, chord, false);
let mut transform = scad!(Translate(vec3(0.0, spacing, 0.0)));
@ -360,7 +359,7 @@ fn span_length(points: &[Point]) -> f32 {
if let Some(last) = last_point {
distance += (last - point).magnitude();
}
last_point = Some(point.clone());
last_point = Some(*point);
}
distance
}

View file

@ -25,7 +25,7 @@ impl SeligFile {
let description = header.next().map(|d| d.to_string());
for line in lines {
let mut numbers = line.split(" ").filter(|n| !n.trim().is_empty());
let mut numbers = line.split(' ').filter(|n| !n.trim().is_empty());
let x = numbers.next().unwrap().parse().unwrap();
let y = numbers.next().unwrap().parse().unwrap();
points.push(Point::new(x, y))
@ -67,7 +67,7 @@ impl Span for Airfoil {
if let Some(last) = last_point {
distance += (last - point).magnitude();
}
last_point = Some(point.clone());
last_point = Some(*point);
}
distance
}
@ -85,25 +85,25 @@ impl Span for Airfoil {
) {
(true, true) => {
// fully within span
points.push(point.clone());
points.push(*point);
}
(false, true) => {
// entering span
let undershoot = distance - range.start;
let part_out = (span - undershoot) / span;
points.push(last.lerp(&point, part_out));
points.push(last.lerp(point, part_out));
}
(true, false) => {
// exiting span
let overshoot = range.end - distance;
let part_in = (span - overshoot) / span;
points.push(last.lerp(&point, part_in));
points.push(last.lerp(point, part_in));
}
_ => {}
}
distance += span;
}
last_point = Some(point.clone());
last_point = Some(*point);
}
points
}