result tag

This commit is contained in:
Umur Ozkul 2022-08-19 22:03:55 +02:00
parent 5c75da4736
commit 4bf5f33f25
2 changed files with 17 additions and 0 deletions

View File

@ -16,3 +16,16 @@ let getValue = (r: result_<'a, 'e>): option<'a> =>
| Ok(v) => Some(v) | Ok(v) => Some(v)
| Error(_) => None | Error(_) => None
} }
@module("ForTS_Result_tag") @scope("ResultTag")
external rtOk_: int = "RtOk"
@module("ForTS_Result_tag") @scope("ResultTag")
external rtError_: int = "RtError"
@genType
let getTag = (r: result_<'a, 'e>): int =>
switch r {
| Ok(_) => rtOk_
| Error(_) => rtError_
}

View File

@ -0,0 +1,4 @@
enum ResultTag {
Ok,
Error,
}