From 3d014ad9854c2b8e1edbb66081ce4ff0fadc59f3 Mon Sep 17 00:00:00 2001 From: Janis Date: Mon, 16 Sep 2024 16:53:58 +0200 Subject: [PATCH] casting of comptimenumbers into other comptime numbers --- src/comptime.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/comptime.rs b/src/comptime.rs index e55470b..cfda42e 100644 --- a/src/comptime.rs +++ b/src/comptime.rs @@ -2223,6 +2223,16 @@ impl ComptimeNumber { Ok(Self::Bool(self.cmp(other)? != Ordering::Greater)) } + pub fn explicit_cast(self, ty: Type) -> Result { + match ty { + Type::Void => Ok(Self::Void), + Type::Bool => self.into_bool(), + Type::Integer(i) => self.into_int(i), + Type::Floating(f) => self.into_float(f), + _ => Err(Error::InvalidConversion), + } + } + pub fn into_bool(self) -> Result { match self { ComptimeNumber::Integral(i) => match i {