Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › compiler_rt/ › memmove.zig › copyForwards
copyForwards
memmove.copyForwards
inline fn copyForwards (
dest : [*]u8 ,
src : [*]const u8 ,
len : usize ,
) void
File
Code
inline fn copyForwards (
dest : [*]u8 ,
src : [*]const u8 ,
len : usize ,
) void {
@setRuntimeSafety (compiler_rt .test_safety );
assert (len >= 2 * @sizeOf (Element ));
const head = src [0 ..@sizeOf (Element )].*;
const tail = src [len - @sizeOf (Element ) ..][0 ..@sizeOf (Element )].*;
const alignment_offset = @alignOf (Element ) - @intFromPtr (src ) % @alignOf (Element );
const n = len - alignment_offset ;
const d = dest + alignment_offset ;
const s = src + alignment_offset ;
copyBlocksAlignedSource (@ptrCast (d ), @ptrCast (@alignCast (s )), n );
// methods only copy a multiple of `copy_size` bytes.
dest [len - @sizeOf (Element ) ..][0 ..@sizeOf (Element )].* = tail ;
dest [0 ..@sizeOf (Element )].* = head ;
}