use espr::{ast::SyntaxTree, codegen::rust::*, ir::IR}; const EXPRESS: &str = r#" SCHEMA test_schema; ENTITY a; x: LIST [0:?] OF REAL; END_ENTITY; ENTITY b; a: LIST [0:?] OF a; END_ENTITY; TYPE c = LIST [0:?] OF REAL; END_TYPE; TYPE d = LIST [0:?] OF a; END_TYPE; END_SCHEMA; "#; #[test] fn list() { let st = SyntaxTree::parse(EXPRESS).unwrap(); let ir = IR::from_syntax_tree(&st).unwrap(); let tt = ir.to_token_stream(CratePrefix::External).to_string(); let tt = rustfmt(tt); insta::assert_snapshot!(tt, @r###" pub mod test_schema { use ruststep::{as_holder, derive_more::*, primitive::*, Holder, TableInit}; use std::collections::HashMap; #[derive(Debug, Clone, PartialEq, Default, TableInit)] pub struct Tables { a: HashMap, b: HashMap, c: HashMap, d: HashMap, } impl Tables { pub fn a_holders(&self) -> &HashMap { &self.a } pub fn b_holders(&self) -> &HashMap { &self.b } pub fn c_holders(&self) -> &HashMap { &self.c } pub fn d_holders(&self) -> &HashMap { &self.d } } #[derive( Clone, Debug, PartialEq, AsRef, Deref, DerefMut, Into, From, :: ruststep_derive :: Holder, )] # [holder (table = Tables)] # [holder (field = c)] #[holder(generate_deserialize)] pub struct C(#[holder(use_place_holder)] pub Vec); #[derive( Clone, Debug, PartialEq, AsRef, Deref, DerefMut, Into, From, :: ruststep_derive :: Holder, )] # [holder (table = Tables)] # [holder (field = d)] #[holder(generate_deserialize)] pub struct D(#[holder(use_place_holder)] pub Vec); #[derive(Debug, Clone, PartialEq, :: derive_new :: new, Holder)] # [holder (table = Tables)] # [holder (field = a)] #[holder(generate_deserialize)] pub struct A { pub x: Vec, } #[derive(Debug, Clone, PartialEq, :: derive_new :: new, Holder)] # [holder (table = Tables)] # [holder (field = b)] #[holder(generate_deserialize)] pub struct B { #[holder(use_place_holder)] pub a: Vec, } } "###); }