From 06fc71d4bc416c52399170fde4b641ed544bbb1c Mon Sep 17 00:00:00 2001 From: bendn Date: Thu, 5 Oct 2023 09:43:50 +0700 Subject: [PATCH] impl boxed for &[u8] --- Cargo.toml | 2 +- src/lib.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 21a9af8..da0a8aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fimg" -version = "0.4.14" +version = "0.4.15" authors = ["bend-n "] license = "MIT" edition = "2021" diff --git a/src/lib.rs b/src/lib.rs index d59f652..1427562 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -251,6 +251,13 @@ impl Image<[u8; N], CHANNELS> { } } +impl Image<&[u8], CHANNELS> { + /// Box this image. + pub fn boxed(self) -> Image, CHANNELS> { + unsafe { Image::new(self.width, self.height, self.buffer.into()) } + } +} + impl Image, CHANNELS> { /// Box this owned image. pub fn boxed(self) -> Image, CHANNELS> {