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
27
28
29
30
31
32
//! This module reexports items from `swc_visit` with some swc-specific traits.

use std::borrow::Cow;

pub use swc_visit::*;

/// A named compiler pass.
pub trait CompilerPass {
    ///
    /// - name should follow hyphen-case.
    /// - an implementation should return same name
    fn name() -> Cow<'static, str>;
}

impl<V> CompilerPass for Repeat<V>
where
    V: CompilerPass + Repeated,
{
    fn name() -> Cow<'static, str> {
        Cow::Owned(format!("repeat({})", V::name()))
    }
}

impl<A, B> CompilerPass for AndThen<A, B>
where
    A: CompilerPass,
    B: CompilerPass,
{
    fn name() -> Cow<'static, str> {
        Cow::Owned(format!("{} -> {}", A::name(), B::name()))
    }
}