mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 22:56:11 +03:00
11d056c777
Move FromVariant to a separate crate
30 lines
520 B
Rust
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>>),
|
|
}
|