add Str.countBytes

This commit is contained in:
Folkert 2022-07-03 14:16:47 +02:00
parent 1f943a5452
commit 3cd56c3184
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
9 changed files with 25 additions and 17 deletions

View file

@ -146,6 +146,7 @@ comptime {
exportStrFn(str.strSplitInPlaceC, "str_split_in_place");
exportStrFn(str.countSegments, "count_segments");
exportStrFn(str.countGraphemeClusters, "count_grapheme_clusters");
exportStrFn(str.countBytes, "count_bytes");
exportStrFn(str.startsWith, "starts_with");
exportStrFn(str.startsWithScalar, "starts_with_scalar");
exportStrFn(str.endsWith, "ends_with");

View file

@ -1184,6 +1184,10 @@ test "countGraphemeClusters: emojis, ut8, and ascii characters" {
try expectEqual(count, 10);
}
pub fn countBytes(string: RocStr) callconv(.C) usize {
return string.len();
}
// Str.startsWith
pub fn startsWith(string: RocStr, prefix: RocStr) callconv(.C) bool {
const bytes_len = string.len();