fast image operations
make boxing more generic
bendn 2025-01-31
parent 3c69b5e · commit e414c8b
-rw-r--r--src/lib.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 6ce1813..cd9a5b1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -388,33 +388,33 @@ impl<const CHANNELS: usize> Image<&[u8], CHANNELS> {
}
}
-impl<const CHANNELS: usize, const N: usize> Image<[u8; N], CHANNELS> {
+impl<const CHANNELS: usize, const N: usize, T> Image<[T; N], CHANNELS> {
/// Box this array image.
- pub fn boxed(self) -> Image<Box<[u8]>, CHANNELS> {
+ pub fn boxed(self) -> Image<Box<[T]>, CHANNELS> {
// SAFETY: size not changed
unsafe { self.map_into() }
}
}
-impl<const CHANNELS: usize> Image<&[u8], CHANNELS> {
+impl<const CHANNELS: usize, T: Copy> Image<&[T], CHANNELS> {
/// Box this image.
- pub fn boxed(self) -> Image<Box<[u8]>, CHANNELS> {
+ pub fn boxed(self) -> Image<Box<[T]>, CHANNELS> {
// SAFETY: size not changed
unsafe { self.map_into() }
}
}
-impl<const CHANNELS: usize> Image<Vec<u8>, CHANNELS> {
+impl<const CHANNELS: usize, T> Image<Vec<T>, CHANNELS> {
/// Box this owned image.
- pub fn boxed(self) -> Image<Box<[u8]>, CHANNELS> {
+ pub fn boxed(self) -> Image<Box<[T]>, CHANNELS> {
// SAFETY: ctor
unsafe { self.map_into() }
}
}
-impl<const CHANNELS: usize> Image<Box<[u8]>, CHANNELS> {
+impl<const CHANNELS: usize, T> Image<Box<[T]>, CHANNELS> {
/// Unbox this vec image.
- pub fn unbox(self) -> Image<Vec<u8>, CHANNELS> {
+ pub fn unbox(self) -> Image<Vec<T>, CHANNELS> {
// SAFETY: ctor
unsafe { self.map_into() }
}