commit 5ac18c703e1d5c12343002ffde208a106fbefad3
parent acd9d5f45c8bc3bb6a9e4b86144c201b0575f751
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 26 Mar 2021 10:18:32 -0400
strings: add warning about runewise operations
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/strings/sub.ha b/strings/sub.ha
@@ -32,6 +32,10 @@ fn utf8_byte_len_unbounded(iter: *iterator) size = {
// index of the Nth rune. If the end argument is given as [strings::end], the
// end of the substring is the end of the original string. The lifetime of the
// substring is the same as that of the original string.
+//
+// Note that substringing runewise is not always the correct thing to do, and it
+// may cause unexpected linguistic errors to arise. You may need to use
+// [unicode::graphsub] instead.
export fn sub(s: str, start: size, end: (size | end)) str = {
let iter = iter(s);
let starti = utf8_byte_len_bounded(&iter, start);