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.

CopyPtrAttrs

mem.CopyPtrAttrs
fn CopyPtrAttrs(
    comptime source: type,
    comptime size: std.builtin.Type.Pointer.Size,
    comptime child: type,
) type

File

lib/std/mem.zig:4325

Code

fn CopyPtrAttrs(
    comptime source: type,
    comptime size: std.builtin.Type.Pointer.Size,
    comptime child: type,
) type {
    const ptr = @typeInfo(source).pointer;
    var attrs = ptr.attrs;
    if (attrs.@"align" == null) {
        const want = @alignOf(ptr.child);
        if (@alignOf(child) != want) {
            attrs.@"align" = want;
        }
    }
    return @Pointer(size, attrs, child, null);
}