1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
crate::ir! {
pub struct IrComment(String);
}

impl IrComment {
    pub fn comment(&self) -> &str {
        &self.0
    }
}

impl From<&str> for IrComment {
    fn from(input: &str) -> Self {
        if input.contains('\n') {
            // Dart's formatter has issues with block comments
            // so we convert them ahead of time.
            let formatted = input
                .split('\n')
                .map(|line| format!("///{line}"))
                .collect::<Vec<_>>()
                .join("\n");
            Self(formatted)
        } else {
            Self(format!("///{input}"))
        }
    }
}