diff --git a/src/ComputeSharp/Extensions/Primitives/VectorExtensions.cs b/src/ComputeSharp/Extensions/Primitives/VectorExtensions.cs
index a5b5c1ab..1c4532ed 100644
--- a/src/ComputeSharp/Extensions/Primitives/VectorExtensions.cs
+++ b/src/ComputeSharp/Extensions/Primitives/VectorExtensions.cs
@@ -1,7 +1,6 @@
using System;
using System.Diagnostics.Contracts;
using System.Numerics;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace ComputeSharp
@@ -17,7 +16,7 @@ namespace ComputeSharp
/// The input array
/// A with items of type , mapping the original array
[Pure]
- public static Span AsFloat2Span(this Vector2[] array) => array.AsSpan().As();
+ public static Span AsFloat2Span(this Vector2[] array) => MemoryMarshal.Cast(array);
///
/// Converts a into a with items of type
@@ -25,7 +24,7 @@ namespace ComputeSharp
/// The input
/// A with items of type , mapping the original
[Pure]
- public static Span AsFloat2Span(this Span span) => span.As();
+ public static Span AsFloat2Span(this Span span) => MemoryMarshal.Cast(span);
///
/// Converts a array into a with items of type
@@ -33,7 +32,7 @@ namespace ComputeSharp
/// The input array
/// A with items of type , mapping the original array
[Pure]
- public static Span AsFloat3Span(this Vector3[] array) => array.AsSpan().As();
+ public static Span AsFloat3Span(this Vector3[] array) => MemoryMarshal.Cast(array);
///
/// Converts a into a with items of type
@@ -41,7 +40,7 @@ namespace ComputeSharp
/// The input
/// A with items of type , mapping the original
[Pure]
- public static Span AsFloat3Span(this Span span) => span.As();
+ public static Span AsFloat3Span(this Span span) => MemoryMarshal.Cast(span);
///
/// Converts a array into a with items of type
@@ -49,7 +48,7 @@ namespace ComputeSharp
/// The input array
/// A with items of type , mapping the original array
[Pure]
- public static Span AsFloat4Span(this Vector4[] array) => array.AsSpan().As();
+ public static Span AsFloat4Span(this Vector4[] array) => MemoryMarshal.Cast(array);
///
/// Converts a into a with items of type
@@ -57,25 +56,6 @@ namespace ComputeSharp
/// The input
/// A with items of type , mapping the original
[Pure]
- public static Span AsFloat4Span(this Span span) => span.As();
-
- ///
- /// Converts a value with items of type to one with items of type
- ///
- /// The type of the input items
- /// The type of items to convert to
- /// The input
- /// A with items of type
- [Pure]
- private static Span As(this Span span)
- where TFrom : unmanaged
- where TTo : unmanaged
- {
-
- if (span.Length == 0) return Span.Empty;
-
- ref TTo r0 = ref Unsafe.As(ref span.GetPinnableReference());
- return MemoryMarshal.CreateSpan(ref r0, span.Length);
- }
+ public static Span AsFloat4Span(this Span span) => MemoryMarshal.Cast(span);
}
}