commit 9016348e9432537b243f598fd54792eac2b32a44
parent f5ac21549bd2a7734cf6ef2d5675345bd1b56afc
Author: Sebastian LaVine <mail@smlavine.com>
Date: Tue, 2 Jan 2024 14:26:39 -0500
strings: Simplify fromutf8
This is a small change, but to a newer reader of the standard library
this is a clearer way of showing the order of the steps the function
takes.
Signed-off-by: Sebastian LaVine <mail@smlavine.com>
Diffstat:
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/strings/utf8.ha b/strings/utf8.ha
@@ -20,9 +20,8 @@ export fn fromutf8_unsafe(in: []u8) str = {
// input. If the slice contains invalid UTF-8 sequences,
// [[encoding::utf8::invalid]] is returned instead.
export fn fromutf8(in: []u8) (str | utf8::invalid) = {
- let s = fromutf8_unsafe(in);
utf8::validate(in)?;
- return s;
+ return fromutf8_unsafe(in);
};
// Converts a string to a UTF-8 byte slice. The return value is borrowed from