use std::rc::Rc; use crate::func::*; pub type NodeRc<'a, BT> = Rc<<BT as BinaryTrees<'a>>::Node>; pub type ReferenceRc<'a, BT> = Rc<<BT as BinaryTrees<'a>>::Reference>; pub type TreeRc<'a, BT> = Rc<<BT as BinaryTrees<'a>>::Tree>; pub type KeyRc<'a, BT> = Rc<<BT as BinaryTrees<'a>>::Key>; pub type Split<'a, BT> = (TreeRc<'a, BT>, TreeRc<'a, BT>, KeyRc<'a, BT>); pub type Wrapped<'a, BT, A> = <<BT as BinaryTrees<'a>>::T as WeakFunctor>::F<'a, A>; pub trait BinaryTrees<'a>: 'a { type Node: 'a; type Reference: 'a; type Tree: 'a; type Key: 'a; type T: 'a + Monad; fn split(node: Self::Node) -> Wrapped<'a, Self, Split<'a, Self>>; fn to_tree(node: Self::Node) -> TreeRc<'a, Self>; fn to_tree_construct(&self, node: Self::Node) -> TreeRc<'a, Self> { Self::to_tree(node) } fn resolve(reference: Self::Reference) -> Wrapped<'a, Self, NodeRc<'a, Self>>; fn equal(rhs: Self::Reference, lhs: Self::Reference) -> bool; fn refer(tree: Self::Tree) -> Option<ReferenceRc<'a, Self>>; }