add more types to detach

This commit is contained in:
Michael Sippel 2024-08-23 13:57:10 +02:00
parent fb796cda04
commit 2749e41fce
Signed by: senvas
GPG key ID: F96CF119C34B64A6

View file

@ -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<RwLock<Context>>) {
// eprintln!("DETACH {:?}", self.get_type());
if let Some(leaf) = self.leaf.as_mut() {
if self.type_tag == Context::parse(&ctx, "Char") {
leaf.detach::<dyn SingletonView<Item = char>>();
if self.type_tag ==
TypeTerm::TypeID(TYPEID_edittree)
{
leaf.detach::< dyn SingletonView<
Item = Arc<RwLock< crate::edit_tree::EditTree >>
> >();
}
if self.type_tag == Context::parse(&ctx, "<Vec Char>") {
leaf.detach_vec::<char>();
else if self.type_tag ==
TypeTerm::TypeID(TYPEID_char)
{
leaf.detach::< dyn SingletonView<Item = char> >();
}
if self.type_tag == Context::parse(&ctx, "<List Char>") {
leaf.detach::<dyn ListView<char>>();
else if self.type_tag == TypeTerm::TypeID(TYPEID_u64)
{
leaf.detach::< dyn SingletonView<Item = u64> >();
}
else if self.type_tag == TypeTerm::App(vec![
TypeTerm::TypeID(TYPEID_vec),
TypeTerm::TypeID(TYPEID_edittree),
]) {
leaf.detach_vec::<
Arc<RwLock< crate::edit_tree::EditTree >>
>();
}
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");
}
}