xenon_codegen/
unsafe.rs

1use core::fmt;
2
3use crate::statement::Statement;
4
5#[derive(Debug, Clone, Default)]
6pub struct Unsafe {
7    pub body: Box<Statement>,
8}
9impl Unsafe {
10    pub fn new(body: Statement) -> Unsafe {
11        Unsafe {
12            body: Box::new(body),
13        }
14    }
15
16    pub fn is_valid(&self) -> bool {
17        self.body.is_valid()
18    }
19}
20impl fmt::Display for Unsafe {
21    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22        match write!(fmt, "unsafe {}", self.body) {
23            Ok(_) => (),
24            Err(e) => return Err(e),
25        }
26        Ok(())
27    }
28}