From c73ab25c9dbe40284cfd38beaf31e2a20a9810de Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 22 Sep 2026 18:22:46 +0200 Subject: refactor(engine): fix portion of clippy lints --- engine/src/image.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'engine/src/image.rs') diff --git a/engine/src/image.rs b/engine/src/image.rs index b01ea53..fd6629e 100644 --- a/engine/src/image.rs +++ b/engine/src/image.rs @@ -70,22 +70,25 @@ impl Image Self::from((color, size)) } + #[must_use] pub fn dimensions(&self) -> Dimens { self.inner.dimensions().into() } + #[must_use] pub fn color_type(&self) -> ColorType { self.inner.color().into() } + #[must_use] pub fn color_space_is_srgb(&self) -> bool { - match self.inner.color_space().primaries { - image_rs::metadata::CicpColorPrimaries::SRgb => true, - _ => false, - } + matches!( + self.inner.color_space().primaries, + image_rs::metadata::CicpColorPrimaries::SRgb + ) } /// Returns a immutable view of a subsection of this image. @@ -93,14 +96,16 @@ impl Image /// /// # Panics /// Panics if the view would be out of bounds + #[must_use] pub fn sub_view(&self, offset: Vec2, size: Dimens) -> SubView<'_> { assert!(offset.x + size.width <= self.dimensions().width); assert!(offset.y + size.height <= self.dimensions().height); - SubView { image: &self, offset, size } + SubView { image: self, offset, size } } + #[must_use] pub fn to_rgba8(&self) -> Self { Self { inner: self.inner.to_rgba8().into() } @@ -108,6 +113,7 @@ impl Image /// Consumes the image and returns a RGBA8 image. If it already is RGBA8, the image is /// returned as is. If not, the image is converted to RGBA8. + #[must_use] pub fn into_rgba8(self) -> Self { Self { @@ -115,11 +121,13 @@ impl Image } } + #[must_use] pub fn as_bytes(&self) -> &[u8] { self.inner.as_bytes() } + #[must_use] pub fn into_bytes(self) -> Vec { self.inner.into_bytes() @@ -303,6 +311,7 @@ pub struct SubView<'image> impl SubView<'_> { + #[must_use] pub fn to_image(&self) -> Image { fn create_sub_image( -- cgit v1.2.3-18-g5258