//! Test case for issue #16. #![allow(dead_code)] use uniplate::derive::Uniplate; use uniplate::Biplate; #[derive(Eq, PartialEq, Clone, Debug, Uniplate)] #[uniplate()] #[biplate(to=Vec,walk_into=[Expr])] enum Stmt { Nothing, Assign(String, Expr), Sequence(Vec), If(Expr, Box, Box), While(Expr, Box), Return(String), } #[derive(Eq, PartialEq, Clone, Debug, Uniplate)] #[uniplate()] #[biplate(to=Vec)] enum Expr { Add(Box, Box), Sub(Box, Box), Mul(Box, Box), Div(Box, Box), Val(i32), Var(String), Neg(Box), } pub fn main() { use Expr::*; use Stmt::*; let inner_stmts = vec![Assign("x".into(),Val(1)), Return("x".into())]; let stmt = Sequence(inner_stmts.clone()); let result = <_ as Biplate>>::children_bi(&stmt).into_iter().collect::>(); assert_eq!(result.len(),1); assert_eq!(result[0],inner_stmts); assert_eq!( as Biplate>>::children_bi(&inner_stmts).len(),1); assert_eq!( as Biplate>>::children_bi(&inner_stmts)[0],inner_stmts); }