Naming of context converters
This commit is contained in:
parent
02dcc7f13f
commit
b17946b88e
@ -5,12 +5,12 @@ use crate::directed::context::{
|
|||||||
};
|
};
|
||||||
use crate::direction::BinaryTreeDirection;
|
use crate::direction::BinaryTreeDirection;
|
||||||
|
|
||||||
pub struct DynamicDirectedBinaryTreeWrapper<CtxRef> {
|
pub struct DynamicDirectedBinaryTreeContextFromContext<CtxRef> {
|
||||||
ctx: CtxRef,
|
ctx: CtxRef,
|
||||||
dir: BinaryTreeDirection,
|
dir: BinaryTreeDirection,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, Ctx: NodeRefContainer> DynamicDirectedBinaryTreeWrapper<&'ctx Ctx> {
|
impl<'ctx, Ctx: NodeRefContainer> DynamicDirectedBinaryTreeContextFromContext<&'ctx Ctx> {
|
||||||
pub fn wrap(ctx: &'ctx Ctx, initialDirection: BinaryTreeDirection) -> Self {
|
pub fn wrap(ctx: &'ctx Ctx, initialDirection: BinaryTreeDirection) -> Self {
|
||||||
return Self {
|
return Self {
|
||||||
ctx,
|
ctx,
|
||||||
@ -19,7 +19,7 @@ impl<'ctx, Ctx: NodeRefContainer> DynamicDirectedBinaryTreeWrapper<&'ctx Ctx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, Ctx: NodeRefContainer> DynamicDirectedBinaryTreeWrapper<&'ctx mut Ctx> {
|
impl<'ctx, Ctx: NodeRefContainer> DynamicDirectedBinaryTreeContextFromContext<&'ctx mut Ctx> {
|
||||||
pub fn wrap(ctx: &'ctx mut Ctx, initialDirection: BinaryTreeDirection) -> Self {
|
pub fn wrap(ctx: &'ctx mut Ctx, initialDirection: BinaryTreeDirection) -> Self {
|
||||||
return Self {
|
return Self {
|
||||||
ctx,
|
ctx,
|
||||||
@ -28,34 +28,34 @@ impl<'ctx, Ctx: NodeRefContainer> DynamicDirectedBinaryTreeWrapper<&'ctx mut Ctx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<CtxRef> DynamicDirectedBinaryTreeWrapper<CtxRef> {
|
impl<CtxRef> DynamicDirectedBinaryTreeContextFromContext<CtxRef> {
|
||||||
pub fn changeDirection(&mut self, newDirection: BinaryTreeDirection) {
|
pub fn changeDirection(&mut self, newDirection: BinaryTreeDirection) {
|
||||||
self.dir = newDirection
|
self.dir = newDirection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ctx: NodeRefContainer> NodeRefContainer for DynamicDirectedBinaryTreeWrapper<&Ctx> {
|
impl<Ctx: NodeRefContainer> NodeRefContainer for DynamicDirectedBinaryTreeContextFromContext<&Ctx> {
|
||||||
type NodeRef = Ctx::NodeRef;
|
type NodeRef = Ctx::NodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ctx: NodeRefContainer> NodeRefContainer for DynamicDirectedBinaryTreeWrapper<&mut Ctx> {
|
impl<Ctx: NodeRefContainer> NodeRefContainer for DynamicDirectedBinaryTreeContextFromContext<&mut Ctx> {
|
||||||
type NodeRef = Ctx::NodeRef;
|
type NodeRef = Ctx::NodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ctx: BinaryTreeParentGetterContext> BinaryTreeParentGetterContext for DynamicDirectedBinaryTreeWrapper<&Ctx> {
|
impl<Ctx: BinaryTreeParentGetterContext> BinaryTreeParentGetterContext for DynamicDirectedBinaryTreeContextFromContext<&Ctx> {
|
||||||
fn getParent(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
fn getParent(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
||||||
return self.ctx.getParent(node);
|
return self.ctx.getParent(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ctx: BinaryTreeParentGetterContext> BinaryTreeParentGetterContext for DynamicDirectedBinaryTreeWrapper<&mut Ctx> {
|
impl<Ctx: BinaryTreeParentGetterContext> BinaryTreeParentGetterContext for DynamicDirectedBinaryTreeContextFromContext<&mut Ctx> {
|
||||||
fn getParent(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
fn getParent(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
||||||
return self.ctx.getParent(node);
|
return self.ctx.getParent(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ctx: BinaryTreeChildrenGetterContext> DirectedBinaryTreeChildrenGetterContext
|
impl<Ctx: BinaryTreeChildrenGetterContext> DirectedBinaryTreeChildrenGetterContext
|
||||||
for DynamicDirectedBinaryTreeWrapper<&Ctx>
|
for DynamicDirectedBinaryTreeContextFromContext<&Ctx>
|
||||||
{
|
{
|
||||||
fn getForwardChild(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
fn getForwardChild(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
||||||
match self.dir {
|
match self.dir {
|
||||||
@ -73,7 +73,7 @@ impl<Ctx: BinaryTreeChildrenGetterContext> DirectedBinaryTreeChildrenGetterConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<Ctx: BinaryTreeChildrenGetterContext> DirectedBinaryTreeChildrenGetterContext
|
impl<Ctx: BinaryTreeChildrenGetterContext> DirectedBinaryTreeChildrenGetterContext
|
||||||
for DynamicDirectedBinaryTreeWrapper<&mut Ctx>
|
for DynamicDirectedBinaryTreeContextFromContext<&mut Ctx>
|
||||||
{
|
{
|
||||||
fn getForwardChild(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
fn getForwardChild(&self, node: Self::NodeRef) -> Option<Self::NodeRef> {
|
||||||
match self.dir {
|
match self.dir {
|
||||||
@ -91,7 +91,7 @@ impl<Ctx: BinaryTreeChildrenGetterContext> DirectedBinaryTreeChildrenGetterConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<Ctx: BinaryTreeChildrenSetterContext> DirectedBinaryTreeChildrenSetterContext
|
unsafe impl<Ctx: BinaryTreeChildrenSetterContext> DirectedBinaryTreeChildrenSetterContext
|
||||||
for DynamicDirectedBinaryTreeWrapper<&mut Ctx>
|
for DynamicDirectedBinaryTreeContextFromContext<&mut Ctx>
|
||||||
{
|
{
|
||||||
fn xSetForwardChild(&mut self, node: Self::NodeRef, newChild: Option<Self::NodeRef>) {
|
fn xSetForwardChild(&mut self, node: Self::NodeRef, newChild: Option<Self::NodeRef>) {
|
||||||
match self.dir {
|
match self.dir {
|
||||||
@ -137,7 +137,7 @@ unsafe impl<Ctx: BinaryTreeChildrenSetterContext> DirectedBinaryTreeChildrenSett
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<Ctx: BinaryTreeParentSetterContext> BinaryTreeParentSetterContext
|
unsafe impl<Ctx: BinaryTreeParentSetterContext> BinaryTreeParentSetterContext
|
||||||
for DynamicDirectedBinaryTreeWrapper<&mut Ctx>
|
for DynamicDirectedBinaryTreeContextFromContext<&mut Ctx>
|
||||||
{
|
{
|
||||||
fn xSetParent(&mut self, node: Self::NodeRef, newParent: Option<Self::NodeRef>) {
|
fn xSetParent(&mut self, node: Self::NodeRef, newParent: Option<Self::NodeRef>) {
|
||||||
self.ctx.xSetParent(node, newParent);
|
self.ctx.xSetParent(node, newParent);
|
||||||
@ -14,11 +14,11 @@ macro_rules! _mut_switch {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LeftDirectedBinaryTreeWalker<CtxRef> {
|
pub struct FixedLeftDirectedBinaryTreeContextFromContext<CtxRef> {
|
||||||
ctx: CtxRef,
|
ctx: CtxRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RightDirectedBinaryTreeWalker<CtxRef> {
|
pub struct FixedRightDirectedBinaryTreeContextFromContext<CtxRef> {
|
||||||
ctx: CtxRef,
|
ctx: CtxRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,8 +32,8 @@ macro_rules! _constructor {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_constructor!(LeftDirectedBinaryTreeWalker));
|
_mut_switch!(_constructor!(FixedLeftDirectedBinaryTreeContextFromContext));
|
||||||
_mut_switch!(_constructor!(RightDirectedBinaryTreeWalker));
|
_mut_switch!(_constructor!(FixedRightDirectedBinaryTreeContextFromContext));
|
||||||
|
|
||||||
macro_rules! _node_ref {
|
macro_rules! _node_ref {
|
||||||
($name:ident $($mut:tt)?) => {
|
($name:ident $($mut:tt)?) => {
|
||||||
@ -43,8 +43,8 @@ macro_rules! _node_ref {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_node_ref!(LeftDirectedBinaryTreeWalker));
|
_mut_switch!(_node_ref!(FixedLeftDirectedBinaryTreeContextFromContext));
|
||||||
_mut_switch!(_node_ref!(RightDirectedBinaryTreeWalker));
|
_mut_switch!(_node_ref!(FixedRightDirectedBinaryTreeContextFromContext));
|
||||||
|
|
||||||
macro_rules! _parent_get {
|
macro_rules! _parent_get {
|
||||||
($name:ident $($mut:tt)?) => {
|
($name:ident $($mut:tt)?) => {
|
||||||
@ -58,8 +58,8 @@ macro_rules! _parent_get {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_parent_get!(LeftDirectedBinaryTreeWalker));
|
_mut_switch!(_parent_get!(FixedLeftDirectedBinaryTreeContextFromContext));
|
||||||
_mut_switch!(_parent_get!(RightDirectedBinaryTreeWalker));
|
_mut_switch!(_parent_get!(FixedRightDirectedBinaryTreeContextFromContext));
|
||||||
|
|
||||||
macro_rules! _children_get {
|
macro_rules! _children_get {
|
||||||
($name:ident $fwd:ident $op:ident $($mut:tt)? ) => {
|
($name:ident $fwd:ident $op:ident $($mut:tt)? ) => {
|
||||||
@ -77,8 +77,8 @@ macro_rules! _children_get {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_children_get!(LeftDirectedBinaryTreeWalker getLeftChild getRightChild));
|
_mut_switch!(_children_get!(FixedLeftDirectedBinaryTreeContextFromContext getLeftChild getRightChild));
|
||||||
_mut_switch!(_children_get!(RightDirectedBinaryTreeWalker getRightChild getLeftChild));
|
_mut_switch!(_children_get!(FixedRightDirectedBinaryTreeContextFromContext getRightChild getLeftChild));
|
||||||
|
|
||||||
macro_rules! _parent_set {
|
macro_rules! _parent_set {
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
@ -99,8 +99,8 @@ macro_rules! _parent_set {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
_parent_set!(LeftDirectedBinaryTreeWalker);
|
_parent_set!(FixedLeftDirectedBinaryTreeContextFromContext);
|
||||||
_parent_set!(RightDirectedBinaryTreeWalker);
|
_parent_set!(FixedRightDirectedBinaryTreeContextFromContext);
|
||||||
|
|
||||||
macro_rules! _children_set {
|
macro_rules! _children_set {
|
||||||
(
|
(
|
||||||
@ -138,12 +138,12 @@ macro_rules! _children_set {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
_children_set!(
|
_children_set!(
|
||||||
LeftDirectedBinaryTreeWalker
|
FixedLeftDirectedBinaryTreeContextFromContext
|
||||||
xSetLeftChild setLeftChild clearLeftChild
|
xSetLeftChild setLeftChild clearLeftChild
|
||||||
xSetRightChild setRightChild clearRightChild
|
xSetRightChild setRightChild clearRightChild
|
||||||
);
|
);
|
||||||
_children_set!(
|
_children_set!(
|
||||||
RightDirectedBinaryTreeWalker
|
FixedRightDirectedBinaryTreeContextFromContext
|
||||||
xSetRightChild setRightChild clearRightChild
|
xSetRightChild setRightChild clearRightChild
|
||||||
xSetLeftChild setLeftChild clearLeftChild
|
xSetLeftChild setLeftChild clearLeftChild
|
||||||
);
|
);
|
||||||
@ -1,2 +0,0 @@
|
|||||||
mod fixed_wrapper;
|
|
||||||
mod dynamic_wrapper;
|
|
||||||
@ -1,5 +1,6 @@
|
|||||||
mod context;
|
mod context;
|
||||||
mod impls;
|
mod fixed_wrapper;
|
||||||
|
mod dynamic_wrapper;
|
||||||
|
|
||||||
pub use context::DirectedBinaryTreeChildrenSetterContext;
|
pub use context::DirectedBinaryTreeChildrenSetterContext;
|
||||||
pub use context::DirectedBinaryTreeChildrenGetterContext;
|
pub use context::DirectedBinaryTreeChildrenGetterContext;
|
||||||
|
|||||||
@ -22,13 +22,13 @@ union _NodeOrNothing<NodeRef> {
|
|||||||
node: ManuallyDrop<NodeRef>,
|
node: ManuallyDrop<NodeRef>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dyn_lr<CtxRef, NodeRef> {
|
struct DynamicParent2NodeGetterClojureFromContext<CtxRef, NodeRef> {
|
||||||
dir: Option<BinaryTreeDirection>,
|
dir: Option<BinaryTreeDirection>,
|
||||||
ctx: CtxRef,
|
ctx: CtxRef,
|
||||||
node: _NodeOrNothing<NodeRef>,
|
node: _NodeOrNothing<NodeRef>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dyn_dir<CtxRef, NodeRef> {
|
struct DynamicParent2NodeGetterClojureFromDirectedContext<CtxRef, NodeRef> {
|
||||||
dir: Option<DirectedBinaryTreeDirection>,
|
dir: Option<DirectedBinaryTreeDirection>,
|
||||||
ctx: CtxRef,
|
ctx: CtxRef,
|
||||||
node: _NodeOrNothing<NodeRef>,
|
node: _NodeOrNothing<NodeRef>,
|
||||||
@ -50,8 +50,8 @@ macro_rules! _constructor {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_constructor!(dyn_lr BinaryTreeDirection));
|
_mut_switch!(_constructor!(DynamicParent2NodeGetterClojureFromContext BinaryTreeDirection));
|
||||||
_mut_switch!(_constructor!(dyn_dir DirectedBinaryTreeDirection));
|
_mut_switch!(_constructor!(DynamicParent2NodeGetterClojureFromDirectedContext DirectedBinaryTreeDirection));
|
||||||
|
|
||||||
macro_rules! _node_ref {
|
macro_rules! _node_ref {
|
||||||
($name:ident $($mut:tt)?) => {
|
($name:ident $($mut:tt)?) => {
|
||||||
@ -61,8 +61,8 @@ macro_rules! _node_ref {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_node_ref!(dyn_lr));
|
_mut_switch!(_node_ref!(DynamicParent2NodeGetterClojureFromContext));
|
||||||
_mut_switch!(_node_ref!(dyn_dir));
|
_mut_switch!(_node_ref!(DynamicParent2NodeGetterClojureFromDirectedContext));
|
||||||
|
|
||||||
macro_rules! _get_child {
|
macro_rules! _get_child {
|
||||||
(
|
(
|
||||||
@ -88,11 +88,11 @@ macro_rules! _get_child {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_get_child!(
|
_mut_switch!(_get_child!(
|
||||||
dyn_lr BinaryTreeChildrenGetterContext
|
DynamicParent2NodeGetterClojureFromContext BinaryTreeChildrenGetterContext
|
||||||
BinaryTreeDirection LEFT getLeftChild RIGHT getRightChild
|
BinaryTreeDirection LEFT getLeftChild RIGHT getRightChild
|
||||||
));
|
));
|
||||||
_mut_switch!(_get_child!(
|
_mut_switch!(_get_child!(
|
||||||
dyn_dir DirectedBinaryTreeChildrenGetterContext
|
DynamicParent2NodeGetterClojureFromDirectedContext DirectedBinaryTreeChildrenGetterContext
|
||||||
DirectedBinaryTreeDirection FORWARD getForwardChild OPPOSITE getOppositeChild
|
DirectedBinaryTreeDirection FORWARD getForwardChild OPPOSITE getOppositeChild
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -137,12 +137,12 @@ macro_rules! _set_child {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_set_child!(
|
_set_child!(
|
||||||
dyn_lr BinaryTreeChildrenSetterContext BinaryTreeDirection
|
DynamicParent2NodeGetterClojureFromContext BinaryTreeChildrenSetterContext BinaryTreeDirection
|
||||||
LEFT xSetLeftChild setLeftChild clearLeftChild
|
LEFT xSetLeftChild setLeftChild clearLeftChild
|
||||||
RIGHT xSetRightChild setRightChild clearRightChild
|
RIGHT xSetRightChild setRightChild clearRightChild
|
||||||
);
|
);
|
||||||
_set_child!(
|
_set_child!(
|
||||||
dyn_dir DirectedBinaryTreeChildrenSetterContext DirectedBinaryTreeDirection
|
DynamicParent2NodeGetterClojureFromDirectedContext DirectedBinaryTreeChildrenSetterContext DirectedBinaryTreeDirection
|
||||||
FORWARD xSetForwardChild setForwardChild clearForwardChild
|
FORWARD xSetForwardChild setForwardChild clearForwardChild
|
||||||
OPPOSITE xSetOppositeChild setOppositeChild clearOppositeChild
|
OPPOSITE xSetOppositeChild setOppositeChild clearOppositeChild
|
||||||
);
|
);
|
||||||
@ -159,6 +159,6 @@ macro_rules! _drop {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_drop!(dyn_lr);
|
_drop!(DynamicParent2NodeGetterClojureFromContext);
|
||||||
_drop!(dyn_dir);
|
_drop!(DynamicParent2NodeGetterClojureFromDirectedContext);
|
||||||
|
|
||||||
|
|||||||
@ -24,13 +24,13 @@ macro_rules! _struct {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Root2NodeContextWrapper<NodeRef> {
|
struct FixedRootParent2NodeGetterClojureFromContext<NodeRef> {
|
||||||
ctx: NodeRef,
|
ctx: NodeRef,
|
||||||
}
|
}
|
||||||
_struct!(Parent2LeftChildContextWrapper);
|
_struct!(FixedLeftParent2NodeGetterClojureFromContext);
|
||||||
_struct!(Parent2RightChildContextWrapper);
|
_struct!(FixedRightParent2NodeGetterClojureFromContext);
|
||||||
_struct!(Parent2ForwardChildContextWrapper);
|
_struct!(FixedForwardParent2NodeGetterClojureFromDirectedContext);
|
||||||
_struct!(Parent2OppositeChildContextWrapper);
|
_struct!(FixedOppositeParent2NodeGetterClojureFromDirectedContext);
|
||||||
|
|
||||||
macro_rules! _constructor {
|
macro_rules! _constructor {
|
||||||
($name:ident $($mut:tt)?) => {
|
($name:ident $($mut:tt)?) => {
|
||||||
@ -42,22 +42,22 @@ macro_rules! _constructor {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, CtxRef: NodeRefContainer + BinaryTreeRootGetter> Root2NodeContextWrapper<&'ctx CtxRef> {
|
impl<'ctx, Ctx: NodeRefContainer + BinaryTreeRootGetter> FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx> {
|
||||||
fn wrap(ctx: &'ctx CtxRef) -> Self {
|
fn wrap(ctx: &'ctx Ctx) -> Self {
|
||||||
return Self { ctx };
|
return Self { ctx };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, CtxRef: NodeRefContainer> Root2NodeContextWrapper<&'ctx mut CtxRef> {
|
impl<'ctx, Ctx: NodeRefContainer> FixedRootParent2NodeGetterClojureFromContext<&'ctx mut Ctx> {
|
||||||
fn wrap(ctx: &'ctx mut CtxRef) -> Self {
|
fn wrap(ctx: &'ctx mut Ctx) -> Self {
|
||||||
return Self { ctx };
|
return Self { ctx };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_constructor!(Parent2LeftChildContextWrapper));
|
_mut_switch!(_constructor!(FixedLeftParent2NodeGetterClojureFromContext));
|
||||||
_mut_switch!(_constructor!(Parent2RightChildContextWrapper));
|
_mut_switch!(_constructor!(FixedRightParent2NodeGetterClojureFromContext));
|
||||||
_mut_switch!(_constructor!(Parent2ForwardChildContextWrapper));
|
_mut_switch!(_constructor!(FixedForwardParent2NodeGetterClojureFromDirectedContext));
|
||||||
_mut_switch!(_constructor!(Parent2OppositeChildContextWrapper));
|
_mut_switch!(_constructor!(FixedOppositeParent2NodeGetterClojureFromDirectedContext));
|
||||||
|
|
||||||
macro_rules! _node_ref {
|
macro_rules! _node_ref {
|
||||||
($name:ident $($mut:tt)?) => {
|
($name:ident $($mut:tt)?) => {
|
||||||
@ -67,25 +67,25 @@ macro_rules! _node_ref {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, CtxRef: NodeRefContainer> NodeRefContainer for Root2NodeContextWrapper<&'ctx CtxRef> {
|
impl<'ctx, Ctx: NodeRefContainer> NodeRefContainer for FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx> {
|
||||||
type NodeRef = CtxRef::NodeRef;
|
type NodeRef = Ctx::NodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, CtxRef: NodeRefContainer> NodeRefContainer
|
impl<'ctx, Ctx: NodeRefContainer> NodeRefContainer
|
||||||
for Root2NodeContextWrapper<&'ctx mut CtxRef>
|
for FixedRootParent2NodeGetterClojureFromContext<&'ctx mut Ctx>
|
||||||
{
|
{
|
||||||
type NodeRef = CtxRef::NodeRef;
|
type NodeRef = Ctx::NodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_node_ref!(Parent2LeftChildContextWrapper));
|
_mut_switch!(_node_ref!(FixedLeftParent2NodeGetterClojureFromContext));
|
||||||
_mut_switch!(_node_ref!(Parent2RightChildContextWrapper));
|
_mut_switch!(_node_ref!(FixedRightParent2NodeGetterClojureFromContext));
|
||||||
_mut_switch!(_node_ref!(Parent2ForwardChildContextWrapper));
|
_mut_switch!(_node_ref!(FixedForwardParent2NodeGetterClojureFromDirectedContext));
|
||||||
_mut_switch!(_node_ref!(Parent2OppositeChildContextWrapper));
|
_mut_switch!(_node_ref!(FixedOppositeParent2NodeGetterClojureFromDirectedContext));
|
||||||
|
|
||||||
macro_rules! _get_child {
|
macro_rules! _get_child {
|
||||||
($name:ident $fn:ident $($mut:tt)? ) => {
|
($name:ident $fn:ident $($mut:tt)? ) => {
|
||||||
impl<'ctx, CtxRef: BinaryTreeChildrenGetterContext> Parent2NodeGetterClojure
|
impl<'ctx, Ctx: BinaryTreeChildrenGetterContext> Parent2NodeGetterClojure
|
||||||
for $name <&'ctx $($mut)? CtxRef, CtxRef::NodeRef>
|
for $name <&'ctx $($mut)? Ctx, Ctx::NodeRef>
|
||||||
{
|
{
|
||||||
fn getChild(&self) -> Self::NodeRef {
|
fn getChild(&self) -> Self::NodeRef {
|
||||||
return self.ctx.$fn(self.node);
|
return self.ctx.$fn(self.node);
|
||||||
@ -94,31 +94,31 @@ macro_rules! _get_child {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, CtxRef: BinaryTreeRootGetter> Parent2NodeGetterClojure
|
impl<'ctx, Ctx: BinaryTreeRootGetter> Parent2NodeGetterClojure
|
||||||
for Root2NodeContextWrapper<&'ctx CtxRef>
|
for FixedRootParent2NodeGetterClojureFromContext<&'ctx Ctx>
|
||||||
{
|
{
|
||||||
fn getChild(&self) -> Self::NodeRef {
|
fn getChild(&self) -> Self::NodeRef {
|
||||||
return self.ctx.getRoot();
|
return self.ctx.getRoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, CtxRef: BinaryTreeRootGetter> Parent2NodeGetterClojure
|
impl<'ctx, Ctx: BinaryTreeRootGetter> Parent2NodeGetterClojure
|
||||||
for Root2NodeContextWrapper<&'ctx mut CtxRef>
|
for FixedRootParent2NodeGetterClojureFromContext<&'ctx mut Ctx>
|
||||||
{
|
{
|
||||||
fn getChild(&self) -> Self::NodeRef {
|
fn getChild(&self) -> Self::NodeRef {
|
||||||
return self.ctx.getRoot();
|
return self.ctx.getRoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_mut_switch!(_get_child!(Parent2LeftChildContextWrapper getLeftChild));
|
_mut_switch!(_get_child!(FixedLeftParent2NodeGetterClojureFromContext getLeftChild));
|
||||||
_mut_switch!(_get_child!(Parent2RightChildContextWrapper getRightChild));
|
_mut_switch!(_get_child!(FixedRightParent2NodeGetterClojureFromContext getRightChild));
|
||||||
_mut_switch!(_get_child!(Parent2ForwardChildContextWrapper getForwardChild));
|
_mut_switch!(_get_child!(FixedForwardParent2NodeGetterClojureFromDirectedContext getForwardChild));
|
||||||
_mut_switch!(_get_child!(Parent2OppositeChildContextWrapper getOppositeChild));
|
_mut_switch!(_get_child!(FixedOppositeParent2NodeGetterClojureFromDirectedContext getOppositeChild));
|
||||||
|
|
||||||
macro_rules! _set_child {
|
macro_rules! _set_child {
|
||||||
($name:ident $xset:ident $set:ident $clear:ident) => {
|
($name:ident $xset:ident $set:ident $clear:ident) => {
|
||||||
impl<'ctx, CtxRef: BinaryTreeChildrenSetterContext> Parent2NodeSetterClojure
|
impl<'ctx, Ctx: BinaryTreeChildrenSetterContext> Parent2NodeSetterClojure
|
||||||
for $name<&'ctx mut CtxRef, CtxRef::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);
|
||||||
@ -135,8 +135,8 @@ macro_rules! _set_child {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ctx, CtxRef: BinaryTreeRootSetter> Parent2NodeSetterClojure
|
impl<'ctx, Ctx: BinaryTreeRootSetter> Parent2NodeSetterClojure
|
||||||
for Root2NodeContextWrapper<&'ctx mut CtxRef>
|
for FixedRootParent2NodeGetterClojureFromContext<&'ctx mut Ctx>
|
||||||
{
|
{
|
||||||
fn xSetChild(&mut self, newChild: Option<Self::NodeRef>) {
|
fn xSetChild(&mut self, newChild: Option<Self::NodeRef>) {
|
||||||
self.ctx.xSetRoot(newChild)
|
self.ctx.xSetRoot(newChild)
|
||||||
@ -151,7 +151,7 @@ impl<'ctx, CtxRef: BinaryTreeRootSetter> Parent2NodeSetterClojure
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_set_child!(Parent2LeftChildContextWrapper xSetLeftChild setLeftChild clearLeftChild);
|
_set_child!(FixedLeftParent2NodeGetterClojureFromContext xSetLeftChild setLeftChild clearLeftChild);
|
||||||
_set_child!(Parent2RightChildContextWrapper xSetRightChild setRightChild clearRightChild);
|
_set_child!(FixedRightParent2NodeGetterClojureFromContext xSetRightChild setRightChild clearRightChild);
|
||||||
_set_child!(Parent2ForwardChildContextWrapper xSetForwardChild setForwardChild clearForwardChild);
|
_set_child!(FixedForwardParent2NodeGetterClojureFromDirectedContext xSetForwardChild setForwardChild clearForwardChild);
|
||||||
_set_child!(Parent2OppositeChildContextWrapper xSetOppositeChild setOppositeChild clearOppositeChild);
|
_set_child!(FixedOppositeParent2NodeGetterClojureFromDirectedContext xSetOppositeChild setOppositeChild clearOppositeChild);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user