From 7a8a37d334c0edca1d893d6a4fa5d935fefcb124 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Sun, 1 Sep 2024 23:23:03 +0200 Subject: [PATCH] reprtree detach add list types --- lib-nested-core/src/repr_tree/node.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib-nested-core/src/repr_tree/node.rs b/lib-nested-core/src/repr_tree/node.rs index 339e177..bc51906 100644 --- a/lib-nested-core/src/repr_tree/node.rs +++ b/lib-nested-core/src/repr_tree/node.rs @@ -19,7 +19,7 @@ use { sync::{Arc, RwLock}, any::Any }, - super::{Context, ReprLeaf, ReprTreeExt, context::{TYPEID_vec, TYPEID_char, TYPEID_u64, TYPEID_edittree}} + super::{Context, ReprLeaf, ReprTreeExt, context::{TYPEID_list, TYPEID_vec, TYPEID_char, TYPEID_u64, TYPEID_edittree}} }; //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> @@ -192,7 +192,7 @@ impl ReprTree { V::Msg: Clone { while let Some(rung_type) = type_ladder.next() { - if &rung_type != self.get_type() { + if &rung_type != self.get_type() { if let Some(next_repr) = self.branches.get(&rung_type) { next_repr.write().unwrap().attach_leaf_to(type_ladder, src_port); } else { @@ -285,8 +285,26 @@ impl ReprTree { ]) { leaf.detach_vec::< u64 >(); } + else if self.type_tag == TypeTerm::App(vec![ + TypeTerm::TypeID(TYPEID_list), + TypeTerm::TypeID(TYPEID_edittree), + ]) { + leaf.detach::< dyn ListView>> >(); + } + else if self.type_tag == TypeTerm::App(vec![ + TypeTerm::TypeID(TYPEID_list), + TypeTerm::TypeID(TYPEID_char), + ]) { + leaf.detach::< dyn ListView >(); + } + else if self.type_tag == TypeTerm::App(vec![ + TypeTerm::TypeID(TYPEID_list), + TypeTerm::TypeID(TYPEID_u64), + ]) { + leaf.detach::< dyn ListView >(); + } else { - eprintln!("cant detach type"); + eprintln!("cant detach type {}", ctx.read().unwrap().type_term_to_str(&self.type_tag)); } }