Skip to content

Commit cb53af8

Browse files
committed
Fix Clippy warnings
1 parent 3973369 commit cb53af8

File tree

17 files changed

+52
-43
lines changed

17 files changed

+52
-43
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/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
//! # Example
4242
//!
4343
//! ```
44+
#![allow(clippy::needless_doctest_main)]
4445
#![doc = include_str!("../examples/hello_tri.rs")]
4546
//! ```
4647

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/color.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ where
731731
{
732732
#[inline]
733733
fn sub_assign(&mut self, rhs: D) {
734-
*self += rhs.neg();
734+
self.add_assign(rhs.neg())
735735
}
736736
}
737737

@@ -754,7 +754,7 @@ where
754754
#[inline]
755755
fn mul_assign(&mut self, rhs: Self) {
756756
for (a, b) in zip(&mut self.0, rhs.0) {
757-
*a = (&*a).mul(b)
757+
*a = Linear::mul(a, b);
758758
}
759759
}
760760
}

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/point.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ where
482482

483483
#[inline]
484484
fn div(self, rhs: f32) -> Self {
485-
self * rhs.recip()
485+
self.mul(1.0 / rhs)
486486
}
487487
}
488488
impl<R: Copy, Sp> DivAssign<f32> for Point<R, Sp>

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
}

0 commit comments

Comments
 (0)