mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-13 15:26:24 +00:00
Str.splitFirst and Str.splitLast
This commit is contained in:
parent
be3800d7fa
commit
eeb271d07f
7 changed files with 135 additions and 3 deletions
|
@ -156,6 +156,7 @@ comptime {
|
|||
exportStrFn(str.strFromFloatC, "from_float");
|
||||
exportStrFn(str.strEqual, "equal");
|
||||
exportStrFn(str.substringUnsafe, "substring_unsafe");
|
||||
exportStrFn(str.getUnsafe, "get_unsafe");
|
||||
exportStrFn(str.strToUtf8C, "to_utf8");
|
||||
exportStrFn(str.fromUtf8C, "from_utf8");
|
||||
exportStrFn(str.fromUtf8RangeC, "from_utf8_range");
|
||||
|
|
|
@ -1194,6 +1194,10 @@ pub fn substringUnsafe(string: RocStr, start: usize, length: usize) callconv(.C)
|
|||
return RocStr.fromSlice(slice);
|
||||
}
|
||||
|
||||
pub fn getUnsafe(string: RocStr, index: usize) callconv(.C) u8 {
|
||||
return string.getUnchecked(index);
|
||||
}
|
||||
|
||||
test "substringUnsafe: start" {
|
||||
const str = RocStr.fromSlice("abcdef");
|
||||
defer str.deinit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue