diff --git a/src/colour/spectrum.rs b/src/colour/spectrum.rs index 03842f1..1c85645 100644 --- a/src/colour/spectrum.rs +++ b/src/colour/spectrum.rs @@ -82,6 +82,7 @@ impl Spectrum { Spectrum { shortest_wavelength: rgb_reference_spectrum::SHORTEST_WAVELENGTH, longest_wavelength: rgb_reference_spectrum::LONGEST_WAVELENGTH, + #[allow(clippy::collapsible_else_if)] samples: if colour.red() <= colour.green() && colour.red() <= colour.blue() { if colour.green() <= colour.blue() { izip![ @@ -178,6 +179,7 @@ impl Spectrum { mod rgb_reference_spectrum { pub const SHORTEST_WAVELENGTH: f64 = 380.0; pub const LONGEST_WAVELENGTH: f64 = 720.0; + #[allow(clippy::excessive_precision)] pub mod reflection { pub const WHITE: [f64; 32] = [ 1.0618958571272863e+00, diff --git a/src/image.rs b/src/image.rs index 65958d9..738a25d 100644 --- a/src/image.rs +++ b/src/image.rs @@ -109,21 +109,21 @@ pub trait NormalizedAsByte { impl NormalizedAsByte for f32 { fn normalized_to_byte(self) -> u8 { - (self * (std::u8::MAX as f32)) as u8 + (self * (u8::MAX as f32)) as u8 } fn byte_to_normalized(byte: u8) -> f32 { - (byte as f32) / (std::u8::MAX as f32) + (byte as f32) / (u8::MAX as f32) } } impl NormalizedAsByte for f64 { fn normalized_to_byte(self) -> u8 { - (self * (std::u8::MAX as f64)) as u8 + (self * (u8::MAX as f64)) as u8 } fn byte_to_normalized(byte: u8) -> f64 { - (byte as f64) / (std::u8::MAX as f64) + (byte as f64) / (u8::MAX as f64) } } diff --git a/src/main.rs b/src/main.rs index a9474bb..44eb102 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,7 @@ fn update_texture(image: &ImageRgbU8, texture: &mut Texture) { .update( Rect::new(0, 0, image.get_width() as u32, image.get_height() as u32), image.get_pixel_data(), - (image.get_width() * ImageRgbU8::num_channels()) as usize, + image.get_width() * ImageRgbU8::num_channels(), ) .expect("Couldn't update texture."); } diff --git a/src/math/mat4.rs b/src/math/mat4.rs index f53e739..c92f3ae 100644 --- a/src/math/mat4.rs +++ b/src/math/mat4.rs @@ -8,6 +8,7 @@ pub struct Mat4 { } impl Mat4 { + #[allow(clippy::too_many_arguments)] pub fn new( m00: T, m01: T, diff --git a/src/mesh.rs b/src/mesh.rs index 0f1126e..54be482 100644 --- a/src/mesh.rs +++ b/src/mesh.rs @@ -47,7 +47,7 @@ mod wavefront_obj { ) -> Vec { if let Some(v0_index) = polygon.iter().next() { let (v0_vertex, v0_normal) = - get_vertex_and_normal(v0_index, &vertex_positions, normal_positions); + get_vertex_and_normal(v0_index, vertex_positions, normal_positions); polygon .iter() .skip(1) diff --git a/src/raycasting/plane.rs b/src/raycasting/plane.rs index 288ea6c..2fb5712 100644 --- a/src/raycasting/plane.rs +++ b/src/raycasting/plane.rs @@ -82,17 +82,17 @@ impl HasBoundingBox for Plane { if v.x() == 0.0 { 0.0 } else { - std::f64::INFINITY + f64::INFINITY }, if v.y() == 0.0 { 0.0 } else { - std::f64::INFINITY + f64::INFINITY }, if v.z() == 0.0 { 0.0 } else { - std::f64::INFINITY + f64::INFINITY }, ) }; diff --git a/src/raycasting/triangle.rs b/src/raycasting/triangle.rs index 829ff07..77404c1 100644 --- a/src/raycasting/triangle.rs +++ b/src/raycasting/triangle.rs @@ -106,6 +106,7 @@ impl HasBoundingBox for Triangle { impl Primitive for Triangle {} fn indices_with_index_of_largest_element_last(v: &Vec3) -> [usize; 3] { + #[allow(clippy::collapsible_else_if)] if v.x() > v.y() { if v.z() > v.x() { [0, 1, 2] diff --git a/src/util/interval.rs b/src/util/interval.rs index 999c0fa..d70d88f 100644 --- a/src/util/interval.rs +++ b/src/util/interval.rs @@ -15,15 +15,15 @@ impl Interval { pub fn empty() -> Self { Interval { - min: std::f64::INFINITY, - max: std::f64::NEG_INFINITY, + min: f64::INFINITY, + max: f64::NEG_INFINITY, } } pub fn infinite() -> Self { Interval { - min: std::f64::NEG_INFINITY, - max: std::f64::INFINITY, + min: f64::NEG_INFINITY, + max: f64::INFINITY, } } diff --git a/src/util/tile_iterator.rs b/src/util/tile_iterator.rs index d916c3d..6eae772 100644 --- a/src/util/tile_iterator.rs +++ b/src/util/tile_iterator.rs @@ -27,7 +27,7 @@ pub struct TileIterator { impl TileIterator { pub fn new(total_width: usize, total_height: usize, tile_size: usize) -> TileIterator { // If tile_size*2 is greater than usize::max_value(), increment would overflow - assert!(tile_size > 0 && tile_size * 2 < usize::max_value()); + assert!(tile_size > 0 && tile_size * 2 < usize::MAX); TileIterator { tile_size, total_width,