stdlib: Add Result and Option types

Since the type checker sucks less now, we can think about maybe
adding some features to the language.

...At some point I'd like to have the type checker clean up
the index map.
This commit is contained in:
2025-04-22 08:00:59 -04:00
parent 8ff17fd475
commit 4747b65414
4 changed files with 51 additions and 7 deletions

21
stdlib/std/result.cl Normal file
View File

@@ -0,0 +1,21 @@
//! The Result type, indicating a fallible operation.
pub enum Result<T, E> {
Ok(T),
Err(E),
}
impl Result {
pub fn is_ok(&self) -> bool {
match self {
Ok(_) => true,
Err(_) => false,
}
}
pub fn is_err(&self) -> bool {
match self {
Ok(_) => false,
Err(_) => true,
}
}
}