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.

asLimbs

limb64.asLimbs
fn asLimbs(v: anytype) Limbs(@TypeOf(v))

File

lib/compiler_rt/limb64.zig:72

Code

fn asLimbs(v: anytype) Limbs(@TypeOf(v)) {
    const T = @TypeOf(v);
    const int_info = @typeInfo(T).int;
    const limb_cnt = comptime limbCount(int_info.bits);
    const ET = @Int(int_info.signedness, limb_cnt * 64);
    const low_to_high: Limbs(T) = @bitCast(@as(ET, v));
    switch (endian) {
        .little => return low_to_high,
        .big => {
            var swapped: Limbs(T) = undefined;
            for (low_to_high, 0..) |x, i| {
                swapped[limb_cnt - i - 1] = x;
            }
            return swapped;
        },
    }
}