add substringUnsafe roc function

This commit is contained in:
Folkert 2022-07-03 17:15:25 +02:00
parent 45eb8b9d77
commit be3800d7fa
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
9 changed files with 29 additions and 0 deletions

View file

@ -82,6 +82,7 @@ pub fn builtin_defs_map(symbol: Symbol, var_store: &mut VarStore) -> Option<Def>
STR_ENDS_WITH => str_ends_with,
STR_COUNT_GRAPHEMES => str_count_graphemes,
STR_COUNT_BYTES=> str_count_bytes,
STR_SUBSTRING_UNSAFE => str_substring_unsafe,
STR_FROM_UTF8 => str_from_utf8,
STR_FROM_UTF8_RANGE => str_from_utf8_range,
STR_TO_UTF8 => str_to_utf8,
@ -1731,6 +1732,11 @@ fn str_count_bytes(symbol: Symbol, var_store: &mut VarStore) -> Def {
lowlevel_1(symbol, LowLevel::StrCountBytes, var_store)
}
/// Str.substringUnsafe : Str, Nat, Nat -> Nat
fn str_substring_unsafe(symbol: Symbol, var_store: &mut VarStore) -> Def {
lowlevel_1(symbol, LowLevel::StrSubstringUnsafe, var_store)
}
/// Str.fromUtf8 : List U8 -> Result Str [BadUtf8 { byteIndex : Nat, problem : Utf8Problem } }]*
fn str_from_utf8(symbol: Symbol, var_store: &mut VarStore) -> Def {
let bytes_var = var_store.fresh();