swc/crates/swc_visit/tests/fold.rs

41 lines
738 B
Rust
Raw Normal View History

2022-02-28 10:12:28 +03:00
#![allow(clippy::ptr_arg)]
2020-05-25 16:53:48 +03:00
use std::any::Any;
2020-07-23 20:18:22 +03:00
use swc_visit::define;
2020-05-25 16:53:48 +03:00
/// Visitable nodes.
pub trait Node: Any {}
impl<T: ?Sized> Node for T where T: Any {}
#[derive(Debug, PartialEq)]
2020-05-25 16:53:48 +03:00
pub struct Item {
// pub field: usize,
// pub inner: Option<Box<Item>>,
pub opt_vec: Option<Vec<Item>>,
pub vec_opt: Vec<Option<Item>>,
pub value: f64,
2020-05-25 16:53:48 +03:00
}
#[derive(Debug, PartialEq)]
2020-05-25 16:53:48 +03:00
pub enum Enum {
Item(Item),
Boxed(Box<Enum>),
2020-05-25 16:53:48 +03:00
}
define!({
pub struct Item {
// pub field: usize,
// pub inner: Option<Box<Item>>,
pub opt_vec: Option<Vec<Item>>,
pub vec_opt: Vec<Option<Item>>,
pub value: f64,
2020-05-25 16:53:48 +03:00
}
pub enum Enum {
Item(Item),
Boxed(Box<Enum>),
2020-05-25 16:53:48 +03:00
}
});