commit 348725230c67e9027e8bf0915930b17ec72aa0ba
parent 4ab971272fcaf9b4b3247d12749e9b3fb7c2a7b7
Author: Sebastian <sebastian@sebsite.pw>
Date: Sat, 7 Sep 2024 16:23:23 -0400
ascii: improve str_(upper|lower) docs
Explicitly document that the buffer can exactly overlap the string, in
case the user doesn't want to allocate a new buffer and the string's
storage is mutable. Also replace "length" with "capacity".
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/ascii/string.ha b/ascii/string.ha
@@ -15,8 +15,9 @@ export fn strlower(s: str) str = {
// Converts all ASCII uppercase characters in a string to their lowercase
// representation, returning a new string. The new string data is stored in the
-// supplied buffer. This function will abort if the buffer's length is too small
-// to fit the entire string.
+// supplied buffer. The buffer is permitted to exactly overlap the string. This
+// function will abort if the buffer's capacity is too small to fit the entire
+// string.
export fn strlower_buf(s: str, buf: []u8) str = {
let it = strings::iter(s);
for (let r => strings::next(&it)) {
@@ -35,8 +36,9 @@ export fn strupper(s: str) str = {
// Converts all ASCII lowercase characters in a string to their uppercase
// representation, returning a new string. The new string data is stored in the
-// supplied buffer. This function will abort if the buffer's length is too small
-// to fit the entire string.
+// supplied buffer. The buffer is permitted to exactly overlap the string. This
+// function will abort if the buffer's capacity is too small to fit the entire
+// string.
export fn strupper_buf(s: str, buf: []u8) str = {
let it = strings::iter(s);
for (let r => strings::next(&it)) {