swc_estree_compat/swcify/
mod.rs

1use std::fmt::Debug;
2
3pub use self::ctx::Context;
4
5mod class;
6mod ctx;
7mod expr;
8mod jsx;
9mod lit;
10mod pat;
11mod program;
12mod stmt;
13mod typescript;
14
15/// Used to convert a babel ast node to
16pub trait Swcify {
17    type Output: Debug + Send + Sync;
18
19    fn swcify(self, ctx: &Context) -> Self::Output;
20}
21
22impl<T> Swcify for Vec<T>
23where
24    T: Swcify,
25{
26    type Output = Vec<T::Output>;
27
28    fn swcify(self, ctx: &Context) -> Self::Output {
29        self.into_iter().map(|v| v.swcify(ctx)).collect()
30    }
31}
32
33impl<T> Swcify for Option<T>
34where
35    T: Swcify,
36{
37    type Output = Option<T::Output>;
38
39    fn swcify(self, ctx: &Context) -> Self::Output {
40        self.map(|v| v.swcify(ctx))
41    }
42}
43
44impl<T> Swcify for Box<T>
45where
46    T: Swcify,
47{
48    type Output = T::Output;
49
50    fn swcify(self, ctx: &Context) -> Self::Output {
51        (*self).swcify(ctx)
52    }
53}