diff --git a/src/affine.rs b/src/affine.rs index d980cb6..acab7cc 100644 --- a/src/affine.rs +++ b/src/affine.rs @@ -18,6 +18,7 @@ impl ImageCloner<'_, CHANNELS> { /// let a = Image::<_, 1>::build(2,2).buf(vec![21,42,90,01]); /// assert_eq!(a.cloner().flip_v().take_buffer(), [90,01,21,42]); /// ``` + #[must_use = "function does not modify the original image"] pub fn flip_v(&self) -> Image, CHANNELS> { let mut out = self.alloc(); for y in 0..self.height() { @@ -37,6 +38,7 @@ impl ImageCloner<'_, CHANNELS> { /// let a = Image::<_,1>::build(2,2).buf(vec![90,01,21,42]); /// assert_eq!(a.cloner().flip_h().take_buffer(), [01,90,42,21]); /// ``` + #[must_use = "function does not modify the original image"] pub fn flip_h(&self) -> Image, CHANNELS> { let mut out = self.alloc(); for y in 0..self.height() { @@ -120,6 +122,7 @@ impl ImageCloner<'_, CHANNELS> { /// let a = Image::<_,1>::build(2,2).buf(vec![00,01,02,10]); /// assert_eq!(a.cloner().rot_180().take_buffer(), vec![10,02,01,00]); /// ``` + #[must_use = "function does not modify the original image"] pub fn rot_180(&self) -> Image, CHANNELS> { let s = (self.width() * self.height()) as usize; let mut v: Vec<[u8; CHANNELS]> = Vec::with_capacity(s); @@ -140,6 +143,7 @@ impl ImageCloner<'_, CHANNELS> { /// # Safety /// /// UB if the image is not square + #[must_use = "function does not modify the original image"] pub unsafe fn rot_90(&self) -> Image, CHANNELS> { let mut out = self.flip_v(); // SAFETY: sqar @@ -151,6 +155,7 @@ impl ImageCloner<'_, CHANNELS> { /// # Safety /// /// UB if the image is not square + #[must_use = "function does not modify the original image"] pub unsafe fn rot_270(&self) -> Image, CHANNELS> { let mut out = self.flip_h(); // SAFETY: sqar diff --git a/src/lib.rs b/src/lib.rs index 0ff6d8b..8243b46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -246,6 +246,7 @@ impl, const CHANNELS: usize> Image ImageCloner<'_, CHANNELS> { ImageCloner::from(self.as_ref()) } diff --git a/src/overlay.rs b/src/overlay.rs index 9c63c41..ba63b74 100644 --- a/src/overlay.rs +++ b/src/overlay.rs @@ -119,6 +119,7 @@ impl Overlay> for Image<&mut [u8], 4> { impl ClonerOverlay<4, 4> for ImageCloner<'_, 4> { #[inline] + #[must_use = "function does not modify the original image"] unsafe fn overlay(&self, with: &Image<&[u8], 4>) -> Image, 4> { let mut out = self.dup(); // SAFETY: same @@ -153,6 +154,8 @@ impl OverlayAt> for Image<&mut [u8], 3> { } impl ClonerOverlayAt<4, 3> for ImageCloner<'_, 3> { + #[inline] + #[must_use = "function does not modify the original image"] unsafe fn overlay_at(&self, with: &Image<&[u8], 4>, x: u32, y: u32) -> Image, 3> { let mut new = self.dup(); // SAFETY: same @@ -225,6 +228,7 @@ impl Overlay> for Image<&mut [u8], 3> { impl ClonerOverlay<4, 3> for ImageCloner<'_, 3> { #[inline] + #[must_use = "function does not modify the original image"] unsafe fn overlay(&self, with: &Image<&[u8], 4>) -> Image, 3> { let mut out = self.dup(); // SAFETY: same @@ -271,6 +275,7 @@ impl OverlayAt> for Image<&mut [u8], 4> { impl ClonerOverlayAt<4, 4> for ImageCloner<'_, 4> { #[inline] + #[must_use = "function does not modify the original image"] /// Overlay with => self at coordinates x, y, without blending, returning a new Image /// /// # Safety