casting of comptimenumbers into other comptime numbers
This commit is contained in:
parent
4e27002fb9
commit
3d014ad985
|
@ -2223,6 +2223,16 @@ impl ComptimeNumber {
|
|||
Ok(Self::Bool(self.cmp(other)? != Ordering::Greater))
|
||||
}
|
||||
|
||||
pub fn explicit_cast(self, ty: Type) -> Result<Self> {
|
||||
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<Self> {
|
||||
match self {
|
||||
ComptimeNumber::Integral(i) => match i {
|
||||
|
|
Loading…
Reference in a new issue