diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-21 00:38:14 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-21 00:38:14 +0000 |
| commit | fd84225099175d54ea20f0d39ddf10ccd2daa381 (patch) | |
| tree | ae42004d20ae3a6f3d4c3c48f999748a1e3e9b0a /std/result.zc | |
| parent | abea7bb0b29f1f1672faff94d1bf26768f214dc1 (diff) | |
Modify codegen, tests should pass now
Diffstat (limited to 'std/result.zc')
| -rw-r--r-- | std/result.zc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/std/result.zc b/std/result.zc index 3794f1a..1d10b1a 100644 --- a/std/result.zc +++ b/std/result.zc @@ -1,4 +1,3 @@ - import "./core.zc" struct Result<T> { @@ -38,6 +37,14 @@ impl Result<T> { return v; } + fn unwrap_ref(self) -> T* { + if (!self.is_ok) { + !"Panic: unwrap_ref called on Err: {self.err}"; + exit(1); + } + return &self.val; + } + fn expect(self, msg: char*) -> T { if (!self.is_ok) { !"Panic: {msg}: {self.err}"; @@ -45,4 +52,4 @@ impl Result<T> { } return self.val; } -} +}
\ No newline at end of file |
