use std::borrow::Borrow; use std::cell::RefCell; use std::fmt::Debug; use std::hash::Hash; use std::rc::{Rc, Weak}; use hashbrown::HashMap; use orchid_api_traits::Coding; use orchid_base::interner::{IStr, IStrHandle, IStrv, IStrvHandle}; use crate::api; trait Branch: 'static { type Token: Clone + Copy + Debug + Hash + PartialEq + Eq + PartialOrd + Ord + Coding + 'static; type Data: 'static + Borrow; type Borrow: ToOwned + ?Sized; type Handle: AsRef; type Interned: Clone; fn mk_interned(t: Self::Token, h: Rc) -> Self::Interned; } struct StrBranch; impl Branch for StrBranch { type Data = String; type Token = api::TStr; type Borrow = str; type Handle = Handle; type Interned = IStr; fn mk_interned(t: Self::Token, h: Rc) -> Self::Interned { IStr(t, h) } } struct StrvBranch; impl Branch for StrvBranch { type Data = Vec; type Token = api::TStrv; type Borrow = [IStr]; type Handle = Handle; type Interned = IStrv; fn mk_interned(t: Self::Token, h: Rc) -> Self::Interned { IStrv(t, h) } } struct Data { token: B::Token, data: Rc, } struct Handle { data: Rc>, parent: Weak>>, } impl IStrHandle for Handle {} impl AsRef for Handle { fn as_ref(&self) -> &str { self.data.data.as_ref().as_ref() } } impl IStrvHandle for Handle {} impl AsRef<[IStr]> for Handle { fn as_ref(&self) -> &[IStr] { self.data.data.as_ref().as_ref() } } struct Rec { handle: Weak, data: Rc>, } struct IntData { by_tok: HashMap>, by_data: HashMap, Rec>, } impl IntData { async fn i(&mut self, q: &B::Borrow) -> B::Interned { todo!() } async fn e(&mut self, q: &B::Token) -> B::Interned { todo!() } } struct Int(Rc>>);