Skip to content

Commit e4aeca0

Browse files
committed
Fix Clippy warnings
1 parent 3973369 commit e4aeca0

File tree

13 files changed

+45
-40
lines changed

13 files changed

+45
-40
lines changed

benches/fill.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ fn gouraud(b: Bencher, sz: f32) {
5656
});
5757
});
5858

59-
let buf = Buf2::new_from(
60-
(1024, 1024),
61-
buf.data().into_iter().map(|c| c.to_color3()),
62-
);
59+
let buf =
60+
Buf2::new_from((1024, 1024), buf.data().iter().map(|c| c.to_color3()));
6361
save_ppm("benches_fill_color.ppm", buf).unwrap();
6462
}
6563

core/examples/hello_tri.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use retrofire_core::prelude::*;
12
use retrofire_core::render::{Model, render, shader};
2-
use retrofire_core::{prelude::*, util::*};
33

44
fn main() {
55
let verts = [
@@ -53,6 +53,7 @@ fn main() {
5353
}
5454
#[cfg(feature = "std")]
5555
{
56+
use retrofire_core::util::pnm;
5657
pnm::save_ppm("triangle.ppm", framebuf).unwrap();
5758
}
5859
}

core/src/geom/prim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ impl<B> Line2<B> {
720720

721721
/// Returns the coefficients [a, b, c] of the line equation ax + by = c.
722722
pub const fn coeffs(&self) -> [f32; 3] {
723-
return self.0.0;
723+
self.0.0
724724
}
725725
}
726726

core/src/math.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Linear algebra and other useful mathematics.
22
//!
33
//! Includes [vectors][self::vec], [matrices][mat], [colors][color],
4-
//! [angles][angle], [Bezier splines][spline] and [pseudo-random numbers][rand],
4+
//! [angles][angle], [splines][spline] and [pseudo-random numbers][rand],
55
//! as well as support for custom [varying][vary] types and utilities such as
66
//! approximate equality comparisons.
77
//!

core/src/math/angle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ impl<B> Vec3<B> {
432432
/// * `r` equals `self.len()`
433433
/// * `az`is the angle between `self` and the xy-plane in the range
434434
/// (-180°, 180°] such that positive `z` maps to *negative* `az`, and
435-
/// * `alt` is the angle between `self` and the xz-plane in the
436-
/// range [-90°, 90°] such that positive `y` maps to positive `alt`.
435+
/// * `alt` is the angle between `self` and the xz-plane in the range
436+
/// [-90°, 90°] such that positive `y` maps to positive `alt`.
437437
///
438438
/// # Examples
439439
/// ```

core/src/math/mat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ where
279279
array::from_fn(|j| array::from_fn(|i| dot(&lhs[j], &rhs[i])))
280280
}
281281

282-
let mut other = other.0.clone();
282+
let mut other = other.0;
283283
transpose(&mut other);
284284
do_compose(&self.0, &other).into()
285285
}

core/src/math/spline.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
//! Bézier curves and splines.
2+
3+
#![allow(clippy::just_underscores_and_digits)]
4+
25
use alloc::vec::Vec;
36
use core::{array::from_fn, fmt::Debug, marker::PhantomData};
47

@@ -369,7 +372,7 @@ where
369372
// = (1 - b2) * p0 + b2 * p1
370373
// = p0 + b2 * (p1 - p0)
371374

372-
p0.add(&p1.sub(&p0).mul(b2)) // Affine part
375+
p0.add(&p1.sub(p0).mul(b2)) // Affine part
373376
.add(&d0.mul(b1).add(&d1.mul(b3))) // Linear part
374377
}
375378

@@ -401,7 +404,7 @@ where
401404

402405
// Only vectors as expected:
403406
// b2·(p1 - p0) + b1·d0 + b3·d1
404-
p1.sub(&p0)
407+
p1.sub(p0)
405408
.mul(b2)
406409
.add(&d0.mul(b1).add(&d1.mul(b3)))
407410
}
@@ -445,7 +448,7 @@ where
445448
.into_iter()
446449
.flat_map(|Ray(p, d)| [p.add(&d.neg()), p.clone(), p.add(&d)])
447450
.collect();
448-
Self::new(pts[1..pts.len() - 1].into_iter().cloned())
451+
Self::new(pts[1..pts.len() - 1].iter().cloned())
449452
}
450453

451454
/// Returns the point of `self` at the given *t* value.
@@ -607,9 +610,9 @@ where
607610
// = P0 - b1·P0 - b2·P0 - b3·P0 + b1·P1 + b2·P2 + b3·P3
608611
// = P0 + b1·(P1 - P0) + b2·(P2 - P0) + b3·(P3 - P0)
609612

610-
let v01 = p1.sub(&p0).mul(b1);
611-
let v02 = &p2.sub(&p0).mul(b2);
612-
let v03 = p3.sub(&p0).mul(b3);
613+
let v01 = p1.sub(p0).mul(b1);
614+
let v02 = p2.sub(p0).mul(b2);
615+
let v03 = p3.sub(p0).mul(b3);
613616
p0.add(&v01.add(&v02).add(&v03).mul(1.0 / 2.0))
614617
}
615618

@@ -637,9 +640,9 @@ where
637640
// = b1·P1 + b2·P2 + b3·P3 - b1·P0 - b2·P0 - b3·P0
638641
// = b1·(P1 - P0) + b2·(P2 - P0) + b3·(P3 - P0)
639642

640-
let v01 = p1.sub(&p0).mul(b1);
641-
let v02 = p2.sub(&p0).mul(b2);
642-
let v03 = p3.sub(&p0).mul(b3);
643+
let v01 = p1.sub(p0).mul(b1);
644+
let v02 = p2.sub(p0).mul(b2);
645+
let v03 = p3.sub(p0).mul(b3);
643646
v01.add(&v02).add(&v03).mul(1.0 / 2.0)
644647
}
645648
}
@@ -678,9 +681,9 @@ where
678681
let b2 = 1.0 + 3.0 * t1 + 3.0 * t2 - 3.0 * t3;
679682
let b3 = t3;
680683

681-
let v01 = p1.sub(&p0).mul(b1);
682-
let v02 = p2.sub(&p0).mul(b2);
683-
let v03 = p3.sub(&p0).mul(b3);
684+
let v01 = p1.sub(p0).mul(b1);
685+
let v02 = p2.sub(p0).mul(b2);
686+
let v03 = p3.sub(p0).mul(b3);
684687
p0.add(&v01.add(&v02).add(&v03).mul(1.0 / 6.0))
685688
}
686689

@@ -708,9 +711,9 @@ where
708711
// = b1·P1 + b2·P2 + b3·P3 - b1·P0 - b2·P0 - b3·P0
709712
// = b1·(P1 - P0) + b2·(P2 - P0) + b3·(P3 - P0)
710713

711-
let v01 = p1.sub(&p0).mul(b1);
712-
let v02 = p2.sub(&p0).mul(b2);
713-
let v03 = p3.sub(&p0).mul(b3);
714+
let v01 = p1.sub(p0).mul(b1);
715+
let v02 = p2.sub(p0).mul(b2);
716+
let v03 = p3.sub(p0).mul(b3);
714717
v01.add(&v02).add(&v03).mul(1.0 / 6.0)
715718
}
716719
}

core/src/math/vec.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
//! Real and projective vectors.
22
//!
33
//! TODO
4+
//!
5+
//!
46
5-
use super::{
6-
Affine, ApproxEq, Linear, Point,
7-
space::{Proj3, Real},
8-
vary::ZDiv,
9-
};
10-
use crate::math::space::Hom;
117
use core::{
128
array,
139
fmt::{Debug, Formatter},
@@ -17,15 +13,21 @@ use core::{
1713
ops::{AddAssign, DivAssign, MulAssign, SubAssign},
1814
};
1915

16+
use super::{
17+
Affine, ApproxEq, Linear, Point,
18+
space::{Hom, Proj3, Real},
19+
vary::ZDiv,
20+
};
21+
2022
//
2123
// Types
2224
//
2325

2426
/// A generic vector type. Represents an element of a vector space.
2527
///
26-
/// or a module,
27-
/// a generalization of a vector space where the scalars can be integers
28-
/// (technically, the scalar type can be any *ring*-like type).
28+
// or a module,
29+
// a generalization of a vector space where the scalars can be integers
30+
// (technically, the scalar type can be any *ring*-like type).
2931
///
3032
/// # Type parameters
3133
/// * `Repr`: Representation of the scalar components of the vector,

core/src/render/cam.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ impl<T: Transform> Camera<T> {
226226
}
227227

228228
/// Renders the given geometry from the viewpoint of this camera.
229+
#[allow(clippy::too_many_arguments)]
229230
pub fn render<B, Prim, Vtx: Clone, Var: Vary, Uni: Copy, Shd>(
230231
&self,
231232
prims: impl AsRef<[Prim]>,

core/src/render/clip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ mod tests {
444444
// 32 16 8 4 2 1
445445

446446
// Outside near == 1
447-
assert_eq!(outcode(&vec(0.0, 0.0, -1.5)), 0b00_0_01);
447+
assert_eq!(outcode(&vec(0.0, 0.0, -1.5)), 0b00_00_01);
448448
// Outside right == 8
449449
assert_eq!(outcode(&vec(2.0, 0.0, 0.0)), 0b00_10_00);
450450
// Outside bottom == 16

0 commit comments

Comments
 (0)