commit cbe691819a15d40b12a37d74ed8c8dd8d8dfc21f parent 39ef0f28cb371cdae62f7c6af0e8afea515f5251 Author: Drew DeVault <sir@cmpwn.com> Date: Tue, 2 Feb 2021 14:01:51 -0500 encoding::utf8: add docs for valid Diffstat:
M | encoding/utf8/decode.ha | | | 4 | ++++ |
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/encoding/utf8/decode.ha b/encoding/utf8/decode.ha @@ -60,6 +60,10 @@ export fn next(d: *decoder) (rune | void | more | invalid) = { return r: rune; }; +// Returns true if a given string or byte slice contains only valid UTF-8 +// sequences. Note that a Hare invariant states that all strings are valid +// UTF-8 - if this ever returns false for a str type, someone is doing something +// funny. export fn valid(src: (str | []u8)) bool = { let decoder = decode(src); for (true) {