mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
Add RocResult
This commit is contained in:
parent
80446a5dfb
commit
4bb0852bd8
2 changed files with 11 additions and 3 deletions
|
@ -1,8 +1,6 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use roc_std::alloca;
|
use roc_std::{alloca, RocCallResult, RocResult, RocStr};
|
||||||
use roc_std::RocCallResult;
|
|
||||||
use roc_std::RocStr;
|
|
||||||
use std::alloc::Layout;
|
use std::alloc::Layout;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
|
|
|
@ -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)]
|
#[allow(non_camel_case_types)]
|
||||||
type c_char = u8;
|
type c_char = u8;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue