Created
November 18, 2020 13:14
-
-
Save DutchGhost/79055e99aa5544b10d730bbe996b45f6 to your computer and use it in GitHub Desktop.
funny usingnamespcae weirdness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
usingnamespace closure: { | |
var hashes: []const usize = &[0]usize{}; | |
break :closure struct { | |
pub fn ctStrHash(comptime str: []const u8) usize { | |
const hash = yourAlgo(str); | |
comptime { | |
for (hashes) |existing| { | |
if (existing == hash) @compileError("collision"); | |
} | |
hashes = hashes ++ [1]usize{hash}; | |
} | |
return hash; | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment