Function copyBackwards [src]
Copy all of source into dest at position 0.
dest.len must be >= source.len.
If the slices overlap, dest.ptr must be >= src.ptr.
Prototype
pub fn copyBackwards(comptime T: type, dest: []T, source: []const T) void
Parameters
T: type
dest: []T
source: []const T
Source
pub fn copyBackwards(comptime T: type, dest: []T, source: []const T) void {
// TODO instead of manually doing this check for the whole array
// and turning off runtime safety, the compiler should detect loops like
// this and automatically omit safety checks for loops
@setRuntimeSafety(false);
assert(dest.len >= source.len);
var i = source.len;
while (i > 0) {
i -= 1;
dest[i] = source[i];
}
}