diff --git a/lib/core/src/string.c.ri b/lib/core/src/string.c.ri index 941022cc4..94efcd854 100644 --- a/lib/core/src/string.c.ri +++ b/lib/core/src/string.c.ri @@ -67,6 +67,21 @@ public struct string < Stringable, Hashable, Throwable { return unsafe { self.ptr[idx] }; } + public func byte_at(self, idx: uint) -> ?uint8 { + if idx >= self.len { + return none; + } + return unsafe { self.ptr[idx] }; + } + + public func rune_at(self, idx: uint) -> ?rune { + runes := self.as_runes(); + if idx >= runes.len { + return none; + } + return runes[idx]; + } + #[inline] public func repeat(self, count: uint) -> Self { return if count == 0 { @@ -505,7 +520,7 @@ public struct string < Stringable, Hashable, Throwable { }; } - /// Returns an array of all the UTF8 runes in the string `self` which is useful + /// Returns an array of all the UTF-8 runes in the string `self` which is useful /// if you want random access to them. public func as_runes(self) -> []rune { mut runes := @vec(rune, self.runes_count());