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.

ProjectId

Minimum information required to identify whether a package is an artifact of a given project.

Package.ProjectId
pub const ProjectId = struct

File

lib/compiler/Maker/Package.zig:172

Code

pub const ProjectId = struct {
    /// Bytes after name.len are set to zero.
    padded_name: [32]u8,
    fingerprint_id: u32,

    pub fn init(name: []const u8, fingerprint_id: u32) ProjectId {
        var padded_name: [32]u8 = @splat(0);
        @memcpy(padded_name[0..name.len], name);
        return .{
            .padded_name = padded_name,
            .fingerprint_id = fingerprint_id,
        };
    }

    pub fn eql(a: *const ProjectId, b: *const ProjectId) bool {
        return a.fingerprint_id == b.fingerprint_id and std.mem.eql(u8, &a.padded_name, &b.padded_name);
    }

    pub fn hash(a: *const ProjectId) u64 {
        const x: u64 = @bitCast(a.padded_name[0..8].*);
        return std.hash.int(x | a.fingerprint_id);
    }
}