There was an error while loading. Please reload this page.
1 parent 2569b36 commit 12666f2Copy full SHA for 12666f2
1 file changed
string/string.mbt
@@ -391,12 +391,14 @@ pub fn String::offset_of_nth_char(
391
}
392
393
///|
394
-/// Returns the Unicode character at the given index.
395
-pub fn String::char_at(self : String, index : Int) -> Char {
396
- guard index >= 0 && index < self.length() else {
397
- abort("index out of bounds")
+/// Returns the Unicode character at the given offset.
+///
+/// This has O(1) complexity.
+pub fn String::char_at(self : String, offset : Int) -> Char {
398
+ guard offset >= 0 && offset < self.length() else {
399
+ abort("offset out of bounds")
400
- self.unsafe_char_at(index)
401
+ self.unsafe_char_at(offset)
402
403
404
0 commit comments