use bmbp_util::{BmbpTree, BmbpTreeUtil}; #[test] fn test_tree() { #[derive(Clone)] struct Dmeo { code: Option, parent_id: Option, name: Option, order: usize, children: Option>, } impl BmbpTree for Dmeo { fn get_code(&self) -> &Option { &self.code } fn set_code(&mut self, code: Option) -> &mut Self { self.code = code; self } fn get_parent_code(&self) -> &Option { &self.parent_id } fn set_parent_code(&mut self, parent_code: Option) -> &mut Self { self.parent_id = parent_code; self } fn get_children(&self) -> &Option> { &self.children } fn get_children_mut(&mut self) -> &mut Option> { &mut self.children } fn set_children(&mut self, children: Option>) -> &mut Self { self.children = children; self } fn get_order(&self) -> usize { 0usize } } let root = Dmeo { code: Some("1".to_string()), parent_id: Some("#".to_string()), name: Some("1".to_string()), order: 2usize, children: None, }; let demo_tree = vec![root]; let tree = BmbpTreeUtil::build_tree::(demo_tree); assert_eq!(tree.len(), 1) }