#[inline] pub fn tr<T>( data: T ) -> Tree<T> { Tree::<T>::new( data )}
#[inline] pub fn fr<T>() -> Forest<T> { Forest::<T>::new() }
impl<T> Neg for Tree<T> {
type Output = Forest<T>;
#[inline]
fn neg( self ) -> Forest<T> {
let mut forest = fr();
forest.push_back( self );
forest
}
}
impl<'a,T:Clone> Neg for &'a Tree<T> {
type Output = Forest<T>;
#[inline]
fn neg( self ) -> Forest<T> {
let mut forest = fr();
forest.push_back( self.clone() );
forest
}
}
impl<T> Sub<Self> for Tree<T> {
type Output = Forest<T>;
#[inline]
fn sub( self, rhs: Self ) -> Forest<T> {
let mut forest = fr();
forest.push_back( self );
forest.push_back( rhs );
forest
}
}
impl<'a,T:Clone> Sub<&'a Tree<T>> for Tree<T> {
type Output = Forest<T>;
#[inline]
fn sub( self, rhs: &'a Tree<T> ) -> Forest<T> {
let mut forest = fr();
forest.push_back( self );
forest.push_back( rhs.clone() );
forest
}
}
impl<'a,T:Clone> Sub<Tree<T>> for &'a Tree<T> {
type Output = Forest<T>;
#[inline]
fn sub( self, rhs: Tree<T> ) -> Forest<T> {
let mut forest = fr();
forest.push_back( self.clone() );
forest.push_back( rhs );
forest
}
}
impl<'a,T:Clone> Sub<Self> for &'a Tree<T> {
type Output = Forest<T>;
#[inline]
fn sub( self, rhs: Self ) -> Forest<T> {
let mut forest = fr();
forest.push_back( self.clone() );
forest.push_back( rhs.clone() );
forest
}
}
impl<T> Div<Forest<T>> for Tree<T> {
type Output = Tree<T>;
#[inline]
fn div( mut self, rhs: Forest<T> ) -> Tree<T> {
self.append( rhs );
self
}
}
impl<'a,T:Clone> Div<&'a Forest<T>> for Tree<T> {
type Output = Tree<T>;
#[inline]
fn div( mut self, rhs: &'a Forest<T> ) -> Tree<T> {
self.append( rhs.clone() );
self
}
}
impl<'a,T:Clone> Div<Forest<T>> for &'a Tree<T> {
type Output = Tree<T>;
#[inline]
fn div( self, rhs: Forest<T> ) -> Tree<T> {
let mut tree = self.clone();
tree.append( rhs );
tree
}
}
impl<'a,T:Clone> Div<&'a Forest<T>> for &'a Tree<T> {
type Output = Tree<T>;
#[inline]
fn div( self, rhs: &'a Forest<T> ) -> Tree<T> {
let mut tree = self.clone();
tree.append( rhs.clone() );
tree
}
}
impl<T> Div<Tree<T>> for Tree<T> {
type Output = Tree<T>;
#[inline]
fn div( mut self, rhs: Tree<T> ) -> Tree<T> {
self.push_back( rhs );
self
}
}
impl<'a,T:Clone> Div<&'a Tree<T>> for Tree<T> {
type Output = Tree<T>;
#[inline]
fn div( mut self, rhs: &'a Tree<T> ) -> Tree<T> {
self.push_back( rhs.clone() );
self
}
}
impl<'a,T:Clone> Div<Tree<T>> for &'a Tree<T> {
type Output = Tree<T>;
#[inline]
fn div( self, rhs: Tree<T> ) -> Tree<T> {
let mut tree = self.clone();
tree.push_back( rhs );
tree
}
}
impl<'a,T:Clone> Div<Self> for &'a Tree<T> {
type Output = Tree<T>;
#[inline]
fn div( self, rhs: Self ) -> Tree<T> {
let mut tree = self.clone();
tree.push_back( rhs.clone() );
tree
}
}
impl<T> Div<()> for Tree<T> {
type Output = Tree<T>;
#[inline]
fn div( self, _rhs: () ) -> Tree<T> {
self
}
}
impl<'a,T:Clone> Div<()> for &'a Tree<T> {
type Output = Tree<T>;
#[inline]
fn div( self, _rhs: () ) -> Tree<T> {
self.clone()
}
}
impl<T> Sub<Tree<T>> for Forest<T> {
type Output = Forest<T>;
#[inline]
fn sub( mut self, rhs: Tree<T> ) -> Self {
self.push_back( rhs );
self
}
}
impl<'a,T:Clone> Sub<&'a Tree<T>> for Forest<T> {
type Output = Forest<T>;
#[inline]
fn sub( mut self, rhs: &'a Tree<T> ) -> Self {
self.push_back( rhs.clone() );
self
}
}
impl<'a,T:Clone> Sub<Tree<T>> for &'a Forest<T> {
type Output = Forest<T>;
#[inline]
fn sub( self, rhs: Tree<T> ) -> Forest<T> {
let mut forest = self.clone();
forest.push_back( rhs );
forest
}
}
impl<'a,'b,T:Clone> Sub<&'b Tree<T>> for &'a Forest<T> {
type Output = Forest<T>;
#[inline]
fn sub( self, rhs: &'b Tree<T> ) -> Forest<T> {
let mut forest = self.clone();
forest.push_back( rhs.clone() );
forest
}
}
impl<T> Sub<Forest<T>> for Forest<T> {
type Output = Forest<T>;
#[inline]
fn sub( mut self, rhs: Self ) -> Self {
self.append( rhs );
self
}
}
impl<'a,T:Clone> Sub<&'a Forest<T>> for Forest<T> {
type Output = Forest<T>;
#[inline]
fn sub( mut self, rhs: &'a Forest<T> ) -> Self {
self.append( rhs.clone() );
self
}
}
impl<'a,T:Clone> Sub<Forest<T>> for &'a Forest<T> {
type Output = Forest<T>;
#[inline]
fn sub( self, mut rhs: Forest<T> ) -> Forest<T> {
rhs.prepend( self.clone() );
rhs
}
}
impl<'a,'b,T:Clone> Sub<&'b Forest<T>> for &'a Forest<T> {
type Output = Forest<T>;
#[inline]
fn sub( self, rhs: &'b Forest<T> ) -> Forest<T> {
let mut forest = self.clone();
forest.append( rhs.clone() );
forest
}
}