From fd84225099175d54ea20f0d39ddf10ccd2daa381 Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Wed, 21 Jan 2026 00:38:14 +0000 Subject: Modify codegen, tests should pass now --- std/result.zc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'std/result.zc') 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 { @@ -38,6 +37,14 @@ impl Result { 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 { } return self.val; } -} +} \ No newline at end of file -- cgit v1.2.3