toasty_core/stmt/
expr_cast.rs1use super::{Expr, Type};
2
3#[derive(Debug, Clone, PartialEq)]
14pub struct ExprCast {
15 pub expr: Box<Expr>,
17
18 pub ty: Type,
20}
21
22impl Expr {
23 pub fn cast(expr: impl Into<Self>, ty: impl Into<Type>) -> Self {
24 ExprCast {
25 expr: Box::new(expr.into()),
26 ty: ty.into(),
27 }
28 .into()
29 }
30
31 pub fn is_cast(&self) -> bool {
32 matches!(self, Self::Cast(_))
33 }
34}
35
36impl From<ExprCast> for Expr {
37 fn from(value: ExprCast) -> Self {
38 Self::Cast(value)
39 }
40}