From c2636d6a745de20e7854be25b336f2792e42f8f2 Mon Sep 17 00:00:00 2001 From: "Robert B. Langer" Date: Sun, 4 May 2025 00:48:20 -0400 Subject: [PATCH] Add reborrowing PixmapMut::as_mut Also add PixmapRef::as_ref for parity --- src/pixmap.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pixmap.rs b/src/pixmap.rs index b49f5a0..82e76fb 100644 --- a/src/pixmap.rs +++ b/src/pixmap.rs @@ -332,6 +332,11 @@ impl<'a> PixmapRef<'a> { } } + /// Reborrows the current container + pub fn as_ref(&self) -> Self { + *self + } + /// Returns pixmap's width. #[inline] pub fn width(&self) -> u32 { @@ -489,6 +494,14 @@ impl<'a> PixmapMut<'a> { } } + /// Reborrows the current container + pub fn as_mut<'b: 'a>(&'b mut self) -> PixmapMut<'b> { + Self { + data: self.data, + size: self.size, + } + } + /// Returns pixmap's width. #[inline] pub fn width(&self) -> u32 {