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

smhasher

Public Function
std.hash.verify.smhasher
pub fn smhasher(comptime hash_fn: anytype) u32

Params

  • hash_fn

File

hash/verify.zig:29
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pub fn smhasher(comptime hash_fn: anytype) u32 {
    const HashFnTy = @typeInfo(@TypeOf(hash_fn)).@"fn";
    const HashResult = HashFnTy.return_type.?;
    const hash_size = @sizeOf(HashResult);

    var buf: [256]u8 = undefined;
    var buf_all: [256 * hash_size]u8 = undefined;

    for (0..256) |i| {
        buf[i] = @intCast(i);
        const h = hashMaybeSeed(hash_fn, 256 - i, buf[0..i]);
        std.mem.writeInt(HashResult, buf_all[i * hash_size ..][0..hash_size], h, .little);
    }

    return @truncate(hashMaybeSeed(hash_fn, 0, buf_all[0..]));
}