Skip to content

Commit

Permalink
Fix some Clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jdahlstrom committed Sep 18, 2024
1 parent 69288fd commit 3840b78
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/src/math/vec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//!
//! TODO

use core::array;
use core::fmt::{Debug, Formatter};
Expand Down
4 changes: 2 additions & 2 deletions core/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ pub fn render<Vtx: Clone, Var: Vary, Uni: Copy, Shd>(
// Fragment shader and rasterization
tri_fill(vs, |scanline| {
// Convert to fragments and shade
stats.frags += target.rasterize(scanline, shader, &ctx);
stats.frags += target.rasterize(scanline, shader, ctx);
});
}
*ctx.stats.borrow_mut() += stats.finish();
}

fn depth_sort<A>(tris: &mut Vec<Tri<ClipVert<A>>>, d: DepthSort) {
fn depth_sort<A>(tris: &mut [Tri<ClipVert<A>>], d: DepthSort) {
tris.sort_unstable_by(|t, u| {
let z = t.0[0].pos.z() + t.0[1].pos.z() + t.0[2].pos.z();
let w = u.0[0].pos.z() + u.0[1].pos.z() + u.0[2].pos.z();
Expand Down
2 changes: 1 addition & 1 deletion core/src/util/pnm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const fn magic(bytes: &[u8; 2]) -> u16 {

impl Display for Format {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "P{}", ((*self as u8) & 0xFF) as char)
write!(f, "P{}", *self as u8 as char)
}
}

Expand Down
4 changes: 2 additions & 2 deletions demos/wasm/src/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ pub fn start() {
);

render(
&[Tri([0, 1, 2])],
[Tri([0, 1, 2])], //
vs,
&sh,
(),
vp,
&mut frame.buf,
&mut frame.ctx,
frame.ctx,
);
Continue(())
});
Expand Down
8 changes: 3 additions & 5 deletions front/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,9 @@ impl Window {
data.len() * 4,
)
};
let img = ImageData::new_with_u8_clamped_array(
Clamped(&u8_data),
self.size.0,
)
.map_err(|_| "could not create image data from color buf")?;
let img =
ImageData::new_with_u8_clamped_array(Clamped(u8_data), self.size.0)
.map_err(|_| "could not create image data from color buf")?;

self.ctx2d
.put_image_data(&img, 0.0, 0.0)
Expand Down
10 changes: 5 additions & 5 deletions geom/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub fn parse_obj(src: impl IntoIterator<Item = u8>) -> Result<Builder<()>> {
.take_while(|&c| c != '\n'),
);

let mut tokens = line.split_ascii_whitespace();
let tokens = &mut line.split_ascii_whitespace();

let Some(item) = tokens.next() else {
continue;
Expand Down Expand Up @@ -191,7 +191,7 @@ fn next<'a>(i: &mut impl Iterator<Item = &'a str>) -> Result<&'a str> {
}

fn parse_face<'a>(
ref mut i: impl Iterator<Item = &'a str>,
i: &mut impl Iterator<Item = &'a str>,
) -> Result<Tri<Indices>> {
let a = parse_indices(next(i)?)?;
let b = parse_indices(next(i)?)?;
Expand All @@ -200,23 +200,23 @@ fn parse_face<'a>(
}

fn parse_texcoord<'a>(
ref mut i: impl Iterator<Item = &'a str>,
i: &mut impl Iterator<Item = &'a str>,
) -> Result<TexCoord> {
let u = next(i)?.parse()?;
let v = next(i)?.parse()?;
Ok(uv(u, v))
}

fn parse_vector<'a>(
ref mut i: impl Iterator<Item = &'a str>,
i: &mut impl Iterator<Item = &'a str>,
) -> Result<Vec3<Real<3, Model>>> {
let x = next(i)?.parse()?;
let y = next(i)?.parse()?;
let z = next(i)?.parse()?;
Ok(vec3(x, y, z).to())
}

fn parse_normal<'a>(i: impl Iterator<Item = &'a str>) -> Result<Normal3> {
fn parse_normal<'a>(i: &mut impl Iterator<Item = &'a str>) -> Result<Normal3> {
parse_vector(i).map(Vector::to)
}

Expand Down
2 changes: 0 additions & 2 deletions geom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ extern crate std;

pub mod io;
pub mod solids;
#[cfg(feature = "teapot")]
pub mod teapot;
2 changes: 1 addition & 1 deletion geom/src/solids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl Octahedron {
}

/// The golden ratio constant φ.
const PHI: f32 = 1.61803401_f32;
const PHI: f32 = 1.618034_f32;
/// Reciprocal of φ.
const R_PHI: f32 = 1.0 / PHI;

Expand Down

0 comments on commit 3840b78

Please sign in to comment.