authorgravatar for wrongnull@gmail.comBogdan Romanyuk <wrongnull@gmail.com> 2023-04-22 13:55:30+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-04-22 13:55:30+03:00
logb22155d352b2f9499596f50b42b86032bcbf168d
treeb16b02283e8f50fc394289428d1f38baa037655f
parentdbdafb6cc503ce5820713dfa79cc956438b7957a
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Add doc comments for ComptimeStringMap

Some parts of stdlib are still undocumented yet.

1 files changed, 4 insertions(+), 0 deletions(-)

lib/std/comptime_string_map.zig+4
...@@ -50,12 +50,16 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs_list: anytype) type {...@@ -50,12 +50,16 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs_list: anytype) type {
50 };50 };
5151
52 return struct {52 return struct {
53 /// Array of `struct { key: []const u8, value: V }` where `value` is `void{}` if `V` is `void`.
54 /// Sorted by `key` length.
53 pub const kvs = precomputed.sorted_kvs;55 pub const kvs = precomputed.sorted_kvs;
5456
57 /// Checks if the map has a value for the key.
55 pub fn has(str: []const u8) bool {58 pub fn has(str: []const u8) bool {
56 return get(str) != null;59 return get(str) != null;
57 }60 }
5861
62 /// Returns the value for the key if any, else null.
59 pub fn get(str: []const u8) ?V {63 pub fn get(str: []const u8) ?V {
60 if (str.len < precomputed.min_len or str.len > precomputed.max_len)64 if (str.len < precomputed.min_len or str.len > precomputed.max_len)
61 return null;65 return null;