use crate::codegen::ir::ty::{IrContext, IrType, IrTypeTrait};
crate::ir! {
pub struct IrTypeBoxed {
pub exist_in_real_api: bool,
pub inner: Box<IrType>,
}
}
impl IrTypeTrait for IrTypeBoxed {
fn visit_children_types<F: FnMut(&IrType) -> bool>(
&self,
f: &mut F,
ir_context: &impl IrContext,
) {
self.inner.visit_types(f, ir_context);
}
fn safe_ident(&self) -> String {
format!(
"box_{}{}",
if self.exist_in_real_api {
""
} else {
"autoadd_"
},
self.inner.safe_ident()
)
}
fn rust_api_type(&self) -> String {
if self.exist_in_real_api {
format!("Box<{}>", self.inner.rust_api_type())
} else {
self.inner.rust_api_type()
}
}
}