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 {