unidok_repr/into_ir/
foreign_impls.rs1use detached_str::StrSlice;
2
3use crate::ast::AstData;
4use crate::IntoIR;
5
6impl<'a> IntoIR<'a> for StrSlice {
7    type IR = &'a str;
8
9    fn into_ir(self, text: &'a str, _: &mut AstData) -> Self::IR {
10        self.to_str(text)
11    }
12}
13
14impl<'a> IntoIR<'a> for () {
15    type IR = ();
16
17    fn into_ir(self, _: &'a str, _: &mut AstData) -> Self::IR {}
18}
19
20impl<'a, T: IntoIR<'a>> IntoIR<'a> for Vec<T> {
21    type IR = Vec<T::IR>;
22
23    fn into_ir(self, text: &'a str, data: &mut AstData) -> Self::IR {
24        self.into_iter().map(|t| t.into_ir(text, data)).collect()
25    }
26}
27
28impl<'a, T: IntoIR<'a>> IntoIR<'a> for Box<T> {
29    type IR = Box<T::IR>;
30
31    fn into_ir(self, text: &'a str, data: &mut AstData) -> Self::IR {
32        Box::new((*self).into_ir(text, data))
33    }
34}
35
36impl<'a, T: IntoIR<'a>> IntoIR<'a> for Option<T> {
37    type IR = Option<T::IR>;
38
39    fn into_ir(self, text: &'a str, data: &mut AstData) -> Self::IR {
40        self.map(|t| t.into_ir(text, data))
41    }
42}