aboutsummaryrefslogtreecommitdiff
path: root/lib/std/comptime_string_map.zig
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2023-04-22 19:10:23 +0200
committerGitHub <noreply@github.com>2023-04-22 19:10:23 +0200
commitc5fb245f60039565f7a5a4de412da815f037ab15 (patch)
tree0a473e618a9982cd9a0209bc053028eef8497cce /lib/std/comptime_string_map.zig
parent428f7452704d1a7b3d9da8e7d4d408db4cbff81f (diff)
parentad634bca9f12a9de641270478a6abf9495b9846f (diff)
downloadzig-c5fb245f60039565f7a5a4de412da815f037ab15.tar.gz
zig-c5fb245f60039565f7a5a4de412da815f037ab15.zip
Merge branch 'master' into autodoc-src-files-dirs
Diffstat (limited to 'lib/std/comptime_string_map.zig')
-rw-r--r--lib/std/comptime_string_map.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/std/comptime_string_map.zig b/lib/std/comptime_string_map.zig
index 267259225c..7620ec7af8 100644
--- a/lib/std/comptime_string_map.zig
+++ b/lib/std/comptime_string_map.zig
@@ -50,12 +50,16 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs_list: anytype) type {
};
return struct {
+ /// Array of `struct { key: []const u8, value: V }` where `value` is `void{}` if `V` is `void`.
+ /// Sorted by `key` length.
pub const kvs = precomputed.sorted_kvs;
+ /// Checks if the map has a value for the key.
pub fn has(str: []const u8) bool {
return get(str) != null;
}
+ /// Returns the value for the key if any, else null.
pub fn get(str: []const u8) ?V {
if (str.len < precomputed.min_len or str.len > precomputed.max_len)
return null;