diff --git a/BeefLibs/corlib/src/Array.bf b/BeefLibs/corlib/src/Array.bf index 53625396..04c16053 100644 --- a/BeefLibs/corlib/src/Array.bf +++ b/BeefLibs/corlib/src/Array.bf @@ -268,6 +268,20 @@ namespace System arrayTo.GetRef(i + dstOffset) = (T2)GetRef(i + srcOffset); } + public void CopyTo(Span destination) + { + Debug.Assert(destination.Length >= mLength); + Internal.MemCpy(destination.Ptr, &GetRef(0), strideof(T) * mLength, alignof(T)); + } + + public void CopyTo(Span destination, int srcOffset, int length) + { + Debug.Assert(length >= 0); + Debug.Assert((uint)srcOffset + (uint)length <= (uint)mLength); + Debug.Assert((uint)length <= (uint)destination.Length); + Internal.MemCpy(destination.Ptr, &GetRef(srcOffset), strideof(T) * length, alignof(T)); + } + public Span.Enumerator GetEnumerator() { return .(this);