]> git.nega.tv - josh/narcissus/commitdiff
Allow creating vulkan slices from mut slices
authorJoshua Simmons <josh@nega.tv>
Thu, 3 Nov 2022 21:17:30 +0000 (22:17 +0100)
committerJoshua Simmons <josh@nega.tv>
Thu, 3 Nov 2022 21:17:30 +0000 (22:17 +0100)
ffi/vulkan-sys/src/lib.rs

index 7eeba0cc53482d236a14b869faa9b41e9be816e5..34ecaf74176578cb064a1ab0777e051178ac6381 100644 (file)
@@ -166,6 +166,25 @@ where
     }
 }
 
+impl<'a, I, T, const PAD: usize> From<&'a mut [T]> for VulkanSlice1<'a, I, T, PAD>
+where
+    I: TryFrom<usize>,
+{
+    fn from(x: &'a mut [T]) -> Self {
+        (x as &[_]).into()
+    }
+}
+
+impl<'a, I, T, const N: usize, const PAD: usize> From<&'a mut [T; N]>
+    for VulkanSlice1<'a, I, T, PAD>
+where
+    I: TryFrom<usize>,
+{
+    fn from(x: &'a mut [T; N]) -> Self {
+        (x as &[T; N]).into()
+    }
+}
+
 #[repr(C)]
 #[repr(packed(4))]
 pub struct VulkanSlice2<'a, I, T0, T1, const PAD: usize> {