Fixed typos in parent2node implementations
This commit is contained in:
parent
b17946b88e
commit
5949fc8cd7
@ -1,7 +1,7 @@
|
|||||||
use crate::NodeRefContainer;
|
use crate::NodeRefContainer;
|
||||||
|
|
||||||
pub trait Parent2NodeGetterClojure: NodeRefContainer {
|
pub trait Parent2NodeGetterClojure: NodeRefContainer {
|
||||||
fn getChild(&self) -> Self::NodeRef;
|
fn getChild(&self) -> Option<Self::NodeRef>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Parent2NodeSetterClojure: NodeRefContainer {
|
pub trait Parent2NodeSetterClojure: NodeRefContainer {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ use super::clojure::Parent2NodeSetterClojure;
|
|||||||
use crate::BinaryTreeDirection;
|
use crate::BinaryTreeDirection;
|
||||||
use crate::NodeRefContainer;
|
use crate::NodeRefContainer;
|
||||||
use crate::context::BinaryTreeRootGetter;
|
use crate::context::BinaryTreeRootGetter;
|
||||||
|
use crate::context::BinaryTreeRootSetter;
|
||||||
use crate::context::{BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext};
|
use crate::context::{BinaryTreeChildrenGetterContext, BinaryTreeChildrenSetterContext};
|
||||||
use crate::directed::{
|
use crate::directed::{
|
||||||
DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext,
|
DirectedBinaryTreeChildrenGetterContext, DirectedBinaryTreeChildrenSetterContext,
|
||||||
@ -9,6 +10,7 @@ use crate::directed::{
|
|||||||
use crate::direction::DirectedBinaryTreeDirection;
|
use crate::direction::DirectedBinaryTreeDirection;
|
||||||
use crate::parent2node::clojure::Parent2NodeGetterClojure;
|
use crate::parent2node::clojure::Parent2NodeGetterClojure;
|
||||||
use std::mem::ManuallyDrop;
|
use std::mem::ManuallyDrop;
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
macro_rules! _mut_switch {
|
macro_rules! _mut_switch {
|
||||||
($macro:tt $excl_mark:tt ( $($args:tt)+) ) => {
|
($macro:tt $excl_mark:tt ( $($args:tt)+) ) => {
|
||||||
@ -76,11 +78,15 @@ macro_rules! _get_child {
|
|||||||
> Parent2NodeGetterClojure
|
> Parent2NodeGetterClojure
|
||||||
for $name <&'ctx $($mut)? Ctx, Ctx::NodeRef>
|
for $name <&'ctx $($mut)? Ctx, Ctx::NodeRef>
|
||||||
{
|
{
|
||||||
fn getChild(&self) -> Self::NodeRef {
|
fn getChild(&self) -> Option<Self::NodeRef> {
|
||||||
match self.dir {
|
match self.dir {
|
||||||
None => return self.ctx.getRoot(),
|
None => return self.ctx.getRoot(),
|
||||||
Some($dir_enum_lbl::$d1_lbl) => self.ctx.$d1_get (self.ctx.node.node),
|
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
||||||
Some($dir_enum_lbl::$d2_lbl) => self.ctx.$d2_get (self.ctx.node.node)
|
self.ctx.$d1_get (*self.node.node.deref())
|
||||||
|
},
|
||||||
|
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
||||||
|
self.ctx.$d2_get (*self.node.node.deref())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,36 +107,50 @@ macro_rules! _set_child {
|
|||||||
$name:ident $ctx_constraint:ident $dir_enum_lbl:ident
|
$name:ident $ctx_constraint:ident $dir_enum_lbl:ident
|
||||||
$d1_lbl:ident $d1_xset:ident $d1_set:ident $d1_clear:ident
|
$d1_lbl:ident $d1_xset:ident $d1_set:ident $d1_clear:ident
|
||||||
$d2_lbl:ident $d2_xset:ident $d2_set:ident $d2_clear:ident
|
$d2_lbl:ident $d2_xset:ident $d2_set:ident $d2_clear:ident
|
||||||
$($mut:tt)?
|
|
||||||
) => {
|
) => {
|
||||||
impl<
|
impl<
|
||||||
'ctx,
|
'ctx,
|
||||||
Ctx: NodeRefContainer + BinaryTreeRootGetter + $ctx_constraint
|
Ctx: NodeRefContainer + BinaryTreeRootSetter + $ctx_constraint
|
||||||
> Parent2NodeSetterClojure
|
> Parent2NodeSetterClojure
|
||||||
for $name <&'ctx $($mut)? Ctx, Ctx::NodeRef>
|
for $name <&'ctx mut Ctx, Ctx::NodeRef>
|
||||||
{
|
{
|
||||||
fn xSetChild(&mut self, newChild: Option<Self::NodeRef>) {
|
fn xSetChild(&mut self, newChild: Option<Self::NodeRef>) {
|
||||||
match self.dir {
|
match self.dir {
|
||||||
None => return self.ctx.xSetRoot(newChild),
|
None => self.ctx.xSetRoot(newChild),
|
||||||
Some($dir_enum_lbl::$d1_lbl) => self.ctx.$d1_xset (self.ctx.node.node, newChild),
|
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
||||||
Some($dir_enum_lbl::$d2_lbl) => self.ctx.$d2_xset (self.ctx.node.node, newChild)
|
self.ctx.$d1_xset (*self.node.node.deref(), newChild)
|
||||||
|
},
|
||||||
|
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
||||||
|
self.ctx.$d2_xset (*self.node.node.deref(), newChild)
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setChild(&mut self, newChild: Self::NodeRef) {
|
fn setChild(&mut self, newChild: Self::NodeRef) {
|
||||||
match self.dir {
|
match self.dir {
|
||||||
None => return self.ctx.setRoot(newChild),
|
None => self.ctx.setRoot(newChild),
|
||||||
Some($dir_enum_lbl::$d1_lbl) => self.ctx.$d1_set (self.ctx.node.node, newChild),
|
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
||||||
Some($dir_enum_lbl::$d2_lbl) => self.ctx.$d2_set (self.ctx.node.node, newChild)
|
self.ctx.$d1_set (*self.node.node.deref(), newChild)
|
||||||
|
},
|
||||||
|
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
||||||
|
self.ctx.$d2_set (*self.node.node.deref(), newChild)
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clearChild(&mut self) {
|
fn clearChild(&mut self) {
|
||||||
match self.dir {
|
match self.dir {
|
||||||
None => return self.ctx.clearRoot(),
|
None => self.ctx.clearRoot(),
|
||||||
Some($dir_enum_lbl::$d1_lbl) => self.ctx.$d1_clear (self.ctx.node.node),
|
Some($dir_enum_lbl::$d1_lbl) => unsafe {
|
||||||
Some($dir_enum_lbl::$d2_lbl) => self.ctx.$d2_clear (self.ctx.node.node)
|
self.ctx.$d1_clear (*self.node.node.deref())
|
||||||
|
},
|
||||||
|
Some($dir_enum_lbl::$d2_lbl) => unsafe {
|
||||||
|
self.ctx.$d2_clear (*self.node.node.deref())
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -42,7 +42,9 @@ macro_rules! _constructor {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, Ctx: NodeRefContainer + BinaryTreeRootGetter> FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx> {
|
impl<'ctx, Ctx: NodeRefContainer + BinaryTreeRootGetter>
|
||||||
|
FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx>
|
||||||
|
{
|
||||||
fn wrap(ctx: &'ctx Ctx) -> Self {
|
fn wrap(ctx: &'ctx Ctx) -> Self {
|
||||||
return Self { ctx };
|
return Self { ctx };
|
||||||
}
|
}
|
||||||
@ -56,8 +58,12 @@ impl<'ctx, Ctx: NodeRefContainer> FixedRootParent2NodeGetterClojureFromContext<&
|
|||||||
|
|
||||||
_mut_switch!(_constructor!(FixedLeftParent2NodeGetterClojureFromContext));
|
_mut_switch!(_constructor!(FixedLeftParent2NodeGetterClojureFromContext));
|
||||||
_mut_switch!(_constructor!(FixedRightParent2NodeGetterClojureFromContext));
|
_mut_switch!(_constructor!(FixedRightParent2NodeGetterClojureFromContext));
|
||||||
_mut_switch!(_constructor!(FixedForwardParent2NodeGetterClojureFromDirectedContext));
|
_mut_switch!(_constructor!(
|
||||||
_mut_switch!(_constructor!(FixedOppositeParent2NodeGetterClojureFromDirectedContext));
|
FixedForwardParent2NodeGetterClojureFromDirectedContext
|
||||||
|
));
|
||||||
|
_mut_switch!(_constructor!(
|
||||||
|
FixedOppositeParent2NodeGetterClojureFromDirectedContext
|
||||||
|
));
|
||||||
|
|
||||||
macro_rules! _node_ref {
|
macro_rules! _node_ref {
|
||||||
($name:ident $($mut:tt)?) => {
|
($name:ident $($mut:tt)?) => {
|
||||||
@ -67,7 +73,9 @@ macro_rules! _node_ref {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, Ctx: NodeRefContainer> NodeRefContainer for FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx> {
|
impl<'ctx, Ctx: NodeRefContainer> NodeRefContainer
|
||||||
|
for FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx>
|
||||||
|
{
|
||||||
type NodeRef = Ctx::NodeRef;
|
type NodeRef = Ctx::NodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,16 +87,20 @@ impl<'ctx, Ctx: NodeRefContainer> NodeRefContainer
|
|||||||
|
|
||||||
_mut_switch!(_node_ref!(FixedLeftParent2NodeGetterClojureFromContext));
|
_mut_switch!(_node_ref!(FixedLeftParent2NodeGetterClojureFromContext));
|
||||||
_mut_switch!(_node_ref!(FixedRightParent2NodeGetterClojureFromContext));
|
_mut_switch!(_node_ref!(FixedRightParent2NodeGetterClojureFromContext));
|
||||||
_mut_switch!(_node_ref!(FixedForwardParent2NodeGetterClojureFromDirectedContext));
|
_mut_switch!(_node_ref!(
|
||||||
_mut_switch!(_node_ref!(FixedOppositeParent2NodeGetterClojureFromDirectedContext));
|
FixedForwardParent2NodeGetterClojureFromDirectedContext
|
||||||
|
));
|
||||||
|
_mut_switch!(_node_ref!(
|
||||||
|
FixedOppositeParent2NodeGetterClojureFromDirectedContext
|
||||||
|
));
|
||||||
|
|
||||||
macro_rules! _get_child {
|
macro_rules! _get_child {
|
||||||
($name:ident $fn:ident $($mut:tt)? ) => {
|
($name:ident $ctx_type:ident $fn:ident $($mut:tt)? ) => {
|
||||||
impl<'ctx, Ctx: BinaryTreeChildrenGetterContext> Parent2NodeGetterClojure
|
impl<'ctx, Ctx: $ctx_type> Parent2NodeGetterClojure
|
||||||
for $name <&'ctx $($mut)? Ctx, Ctx::NodeRef>
|
for $name <&'ctx $($mut)? Ctx, Ctx::NodeRef>
|
||||||
{
|
{
|
||||||
fn getChild(&self) -> Self::NodeRef {
|
fn getChild(&self) -> Option<Self::NodeRef> {
|
||||||
return self.ctx.$fn(self.node);
|
return self.ctx.$fn (self.node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -97,7 +109,7 @@ macro_rules! _get_child {
|
|||||||
impl<'ctx, Ctx: BinaryTreeRootGetter> Parent2NodeGetterClojure
|
impl<'ctx, Ctx: BinaryTreeRootGetter> Parent2NodeGetterClojure
|
||||||
for FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx>
|
for FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx>
|
||||||
{
|
{
|
||||||
fn getChild(&self) -> Self::NodeRef {
|
fn getChild(&self) -> Option<Self::NodeRef> {
|
||||||
return self.ctx.getRoot();
|
return self.ctx.getRoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,21 +117,31 @@ impl<'ctx, Ctx: BinaryTreeRootGetter> Parent2NodeGetterClojure
|
|||||||
impl<'ctx, Ctx: BinaryTreeRootGetter> Parent2NodeGetterClojure
|
impl<'ctx, Ctx: BinaryTreeRootGetter> Parent2NodeGetterClojure
|
||||||
for FixedRootParent2NodeGetterClojureFromContext<&'ctx mut Ctx>
|
for FixedRootParent2NodeGetterClojureFromContext<&'ctx mut Ctx>
|
||||||
{
|
{
|
||||||
fn getChild(&self) -> Self::NodeRef {
|
fn getChild(&self) -> Option<Self::NodeRef> {
|
||||||
return self.ctx.getRoot();
|
return self.ctx.getRoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_get_child!(FixedLeftParent2NodeGetterClojureFromContext getLeftChild));
|
_mut_switch!(_get_child!(
|
||||||
_mut_switch!(_get_child!(FixedRightParent2NodeGetterClojureFromContext getRightChild));
|
FixedLeftParent2NodeGetterClojureFromContext
|
||||||
_mut_switch!(_get_child!(FixedForwardParent2NodeGetterClojureFromDirectedContext getForwardChild));
|
BinaryTreeChildrenGetterContext getLeftChild
|
||||||
_mut_switch!(_get_child!(FixedOppositeParent2NodeGetterClojureFromDirectedContext getOppositeChild));
|
));
|
||||||
|
_mut_switch!(_get_child!(
|
||||||
|
FixedRightParent2NodeGetterClojureFromContext
|
||||||
|
BinaryTreeChildrenGetterContext getRightChild
|
||||||
|
));
|
||||||
|
_mut_switch!(_get_child!(
|
||||||
|
FixedForwardParent2NodeGetterClojureFromDirectedContext
|
||||||
|
DirectedBinaryTreeChildrenGetterContext getForwardChild
|
||||||
|
));
|
||||||
|
_mut_switch!(_get_child!(
|
||||||
|
FixedOppositeParent2NodeGetterClojureFromDirectedContext
|
||||||
|
DirectedBinaryTreeChildrenGetterContext getOppositeChild
|
||||||
|
));
|
||||||
|
|
||||||
macro_rules! _set_child {
|
macro_rules! _set_child {
|
||||||
($name:ident $xset:ident $set:ident $clear:ident) => {
|
($name:ident $ctx:ident $xset:ident $set:ident $clear:ident) => {
|
||||||
impl<'ctx, Ctx: BinaryTreeChildrenSetterContext> Parent2NodeSetterClojure
|
impl<'ctx, Ctx: $ctx> Parent2NodeSetterClojure for $name<&'ctx mut Ctx, Ctx::NodeRef> {
|
||||||
for $name<&'ctx mut Ctx, Ctx::NodeRef>
|
|
||||||
{
|
|
||||||
fn xSetChild(&mut self, newChild: Option<Self::NodeRef>) {
|
fn xSetChild(&mut self, newChild: Option<Self::NodeRef>) {
|
||||||
self.ctx.$xset(self.node, newChild);
|
self.ctx.$xset(self.node, newChild);
|
||||||
}
|
}
|
||||||
@ -151,7 +173,19 @@ impl<'ctx, Ctx: BinaryTreeRootSetter> Parent2NodeSetterClojure
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_set_child!(FixedLeftParent2NodeGetterClojureFromContext xSetLeftChild setLeftChild clearLeftChild);
|
_set_child!(
|
||||||
_set_child!(FixedRightParent2NodeGetterClojureFromContext xSetRightChild setRightChild clearRightChild);
|
FixedLeftParent2NodeGetterClojureFromContext
|
||||||
_set_child!(FixedForwardParent2NodeGetterClojureFromDirectedContext xSetForwardChild setForwardChild clearForwardChild);
|
BinaryTreeChildrenSetterContext xSetLeftChild setLeftChild clearLeftChild
|
||||||
_set_child!(FixedOppositeParent2NodeGetterClojureFromDirectedContext xSetOppositeChild setOppositeChild clearOppositeChild);
|
);
|
||||||
|
_set_child!(
|
||||||
|
FixedRightParent2NodeGetterClojureFromContext
|
||||||
|
BinaryTreeChildrenSetterContext xSetRightChild setRightChild clearRightChild
|
||||||
|
);
|
||||||
|
_set_child!(
|
||||||
|
FixedForwardParent2NodeGetterClojureFromDirectedContext
|
||||||
|
DirectedBinaryTreeChildrenSetterContext xSetForwardChild setForwardChild clearForwardChild
|
||||||
|
);
|
||||||
|
_set_child!(
|
||||||
|
FixedOppositeParent2NodeGetterClojureFromDirectedContext
|
||||||
|
DirectedBinaryTreeChildrenSetterContext xSetOppositeChild setOppositeChild clearOppositeChild
|
||||||
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user