Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Private Function

extraFieldLen

Private Function
std.Build.Configuration.Storage.extraFieldLen
fn extraFieldLen(field: anytype) usize

Params

  • field

File

Build/Configuration.zig:2942
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
    fn extraFieldLen(field: anytype) usize {
        const Field = @TypeOf(field);
        return switch (@typeInfo(Field)) {
            .void => 0,
            .int => |info| switch (info.bits) {
                32 => 1,
                64 => 2,
                else => comptime unreachable,
            },
            .@"enum" => 1,
            .@"struct" => |info| switch (info.layout) {
                .@"packed" => switch (info.backing_integer.?) {
                    u32 => 1,
                    u64 => 2,
                    else => comptime unreachable,
                },
                .auto => switch (Field.storage) {
                    .flag_optional, .enum_optional => (@sizeOf(Field.Value) + 3) / 4,
                    .extended => 1,
                    .length_prefixed_list,
                    .flag_length_prefixed_list,
                    .flag_list,
                    => 1 + @divExact(@sizeOf(Field.Elem), @sizeOf(u32)) * field.slice.len,
                    .multi_list => 1 + field.mal.len * @typeInfo(Field.Elem).@"struct".field_names.len,
                    .union_list => Field.extraLen(field.len),
                    .flag_union => switch (field.u) {
                        inline else => |v| extraFieldLen(v),
                    },
                },
                .@"extern" => @divExact(@sizeOf(Field), @sizeOf(u32)),
            },
            else => @compileError("bad type: " ++ @typeName(Field)),
        };
    }