import "./core.zc" struct Option { is_some: bool; val: T; } impl Option { fn Some(v: T) -> Option { return Option { is_some: true, val: v }; } fn None() -> Option { return Option { is_some: false, val: 0 }; } fn is_some(self) -> bool { return self.is_some; } fn is_none(self) -> bool { return !self.is_some; } fn unwrap(self) -> T { if (!self.is_some) { !"Panic: unwrap called on None"; exit(1); } return self.val; } fn unwrap_or(self, def_val: T) -> T { if (self.is_some) { return self.val; } return def_val; } fn expect(self, msg: char*) -> T { if (!self.is_some) { !"Panic: {msg}"; exit(1); } return self.val; } fn or_else(self, other: Option) -> Option { if self.is_some { return *self; } return other; } }