From https://github.com/dotnet/corefx/issues/26139#issuecomment-358090527:
Move and rename NonPortableCast to MemoryMarshal.Cast
Current API:
namespace System
{
public static partial class MemoryExtensions
{
public static ReadOnlySpan<TTo> NonPortableCast<TFrom, TTo>(this ReadOnlySpan<TFrom> source) where TFrom : struct where TTo : struct { throw null; }
public static Span<TTo> NonPortableCast<TFrom, TTo>(this Span<TFrom> source) where TFrom : struct where TTo : struct { throw null; }
}
}
Proposed API:
namespace System.Runtime.InteropServices
{
public static partial class MemoryMarshal
{
public static bool TryCast<TFrom, TTo>(ReadOnlySpan<TFrom> source, out ReadOnlySpan<TTo> output) where TFrom : struct where TTo : struct { throw null; }
public static bool TryCast<TFrom, TTo>(Span<TFrom> source, out Span<TTo> output) where TFrom : struct where TTo : struct { throw null; }
}
}
Edit: Removed this
Edit by @ianhays: Changed Cast to TryCast per discussion
cc @jkotas, @KrzysztofCwalina
From https://github.com/dotnet/corefx/issues/26139#issuecomment-358090527:
Move and rename NonPortableCast to MemoryMarshal.Cast
Current API:
Proposed API:
Edit: Removed
thisEdit by @ianhays: Changed
CasttoTryCastper discussioncc @jkotas, @KrzysztofCwalina