mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
[WIP] Setup rust side to call Str.fromUtf8
This commit is contained in:
parent
d7ba522155
commit
815f633a58
14 changed files with 371 additions and 18 deletions
|
@ -4,7 +4,7 @@ use roc_module::symbol::Symbol;
|
|||
use roc_region::all::Region;
|
||||
use roc_types::builtin_aliases::{
|
||||
bool_type, dict_type, float_type, int_type, list_type, nat_type, num_type, ordering_type,
|
||||
result_type, set_type, str_type,
|
||||
result_type, set_type, str_type, str_utf8_problem_type, u8_type,
|
||||
};
|
||||
use roc_types::solved_types::SolvedType;
|
||||
use roc_types::subs::VarId;
|
||||
|
@ -539,6 +539,23 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
top_level_function(vec![int_type(flex(TVAR1))], Box::new(str_type())),
|
||||
);
|
||||
|
||||
// fromUtf8 : List U8 -> Result Str [ BadUtf8 Utf8Problem ]*
|
||||
let bad_utf8 = SolvedType::TagUnion(
|
||||
vec![(
|
||||
TagName::Global("BadUtf8".into()),
|
||||
vec![str_utf8_problem_type()],
|
||||
)],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
add_type(
|
||||
Symbol::STR_FROM_UTF8,
|
||||
top_level_function(
|
||||
vec![list_type(u8_type())],
|
||||
Box::new(result_type(str_type(), bad_utf8)),
|
||||
),
|
||||
);
|
||||
|
||||
// List module
|
||||
|
||||
// get : List elem, Nat -> Result elem [ OutOfBounds ]*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue