Add RocResult

This commit is contained in:
Richard Feldman 2021-04-06 22:44:25 -04:00
parent 80446a5dfb
commit 4bb0852bd8
2 changed files with 11 additions and 3 deletions

View file

@ -1,8 +1,6 @@
#![allow(non_snake_case)]
use roc_std::alloca;
use roc_std::RocCallResult;
use roc_std::RocStr;
use roc_std::{alloca, RocCallResult, RocResult, RocStr};
use std::alloc::Layout;
use std::time::SystemTime;

View file

@ -493,6 +493,16 @@ impl Drop for RocStr {
}
}
/// Like a Rust Result, but with Roc's fixed discriminant size of u64, and
/// with Roc's Err = 0, Ok = 1 discriminant numbers.
///
/// Using Rust's Result instead of this will not work properly with Roc code!
#[repr(u64)]
pub enum RocResult<Ok, Err> {
Err(Err),
Ok(Ok),
}
#[allow(non_camel_case_types)]
type c_char = u8;