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. Public Function

getDevicePath

Public Function
std.os.uefi.protocol.device_path.DevicePath.getDevicePath
pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath

Params

File

os/uefi/protocol/device_path.zig:84
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
    pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath {
        const u_info = @typeInfo(uefi.DevicePath).@"union";
        inline for (u_info.field_names, u_info.field_types) |ufield_name, ufield_type| {
            const enum_value = std.meta.stringToEnum(uefi.DevicePath.Type, ufield_name);

            // Got the associated union type for self.type, now
            // we need to initialize it and its subtype
            if (self.type == enum_value) {
                const subtype = self.initSubtype(ufield_type);
                if (subtype) |sb| {
                    // e.g. return .{ .hardware = .{ .pci = @ptrCast(...) } }
                    return @unionInit(uefi.DevicePath, ufield_name, sb);
                }
            }
        }

        return null;
    }