swc/common/tests/fold_bound.rs
강동윤 11d056c777
Extract FromVariant (#586)
Move FromVariant to a separate crate
2020-01-15 18:00:08 +09:00

30 lines
520 B
Rust

//! Ensures that #[derive(Fold)] works with generic types.
#![feature(specialization)]
use std::fmt::Debug;
use swc_common::{AstNode, Fold};
pub trait Ast: Copy + Eq + Debug {
type CustomExpr: AstNode;
}
#[derive(Fold)]
pub struct Stmt<A: Ast> {
#[fold(bound)]
pub expr: Expr<A>,
}
#[derive(Fold)]
pub struct Expr<A: Ast> {
#[fold(bound)]
pub node: ExprKind<A>,
}
#[derive(Fold)]
pub enum ExprKind<A: Ast> {
Custom(#[fold(bound)] A::CustomExpr),
/// Recursive
Stmt(Box<Stmt<A>>),
}