From 2749e41fceaa210fb7e0debe83e3e0b68737a960 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Fri, 23 Aug 2024 13:57:10 +0200 Subject: [PATCH] add more types to detach --- lib-nested-core/src/repr_tree/node.rs | 47 ++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/lib-nested-core/src/repr_tree/node.rs b/lib-nested-core/src/repr_tree/node.rs index efb52fb..339e177 100644 --- a/lib-nested-core/src/repr_tree/node.rs +++ b/lib-nested-core/src/repr_tree/node.rs @@ -241,23 +241,52 @@ impl ReprTree { leaf.attach_to(src_port); self.leaf = Some(leaf); - } else { + } else { self.leaf = Some(ReprLeaf::from_view(src_port)); } - } + } } pub fn detach(&mut self, ctx: &Arc>) { -// eprintln!("DETACH {:?}", self.get_type()); if let Some(leaf) = self.leaf.as_mut() { - if self.type_tag == Context::parse(&ctx, "Char") { - leaf.detach::>(); + if self.type_tag == + TypeTerm::TypeID(TYPEID_edittree) + { + leaf.detach::< dyn SingletonView< + Item = Arc> + > >(); } - if self.type_tag == Context::parse(&ctx, "") { - leaf.detach_vec::(); + else if self.type_tag == + TypeTerm::TypeID(TYPEID_char) + { + leaf.detach::< dyn SingletonView >(); } - if self.type_tag == Context::parse(&ctx, "") { - leaf.detach::>(); + else if self.type_tag == TypeTerm::TypeID(TYPEID_u64) + { + leaf.detach::< dyn SingletonView >(); + } + else if self.type_tag == TypeTerm::App(vec![ + TypeTerm::TypeID(TYPEID_vec), + TypeTerm::TypeID(TYPEID_edittree), + ]) { + leaf.detach_vec::< + Arc> + >(); + } + else if self.type_tag == TypeTerm::App(vec![ + TypeTerm::TypeID(TYPEID_vec), + TypeTerm::TypeID(TYPEID_char), + ]) { + leaf.detach_vec::< char >(); + } + else if self.type_tag == TypeTerm::App(vec![ + TypeTerm::TypeID(TYPEID_vec), + TypeTerm::TypeID(TYPEID_u64), + ]) { + leaf.detach_vec::< u64 >(); + } + else { + eprintln!("cant detach type"); } }