pub( crate ) mod private
{
use crate::prelude::*;
use wtools::prelude::*;
use core::fmt;
use core::cell::RefCell;
use core::ops::Deref;
use std::sync::Arc;
#[ repr( transparent ) ]
pub struct NodeCell< Node >( Arc< RefCell< Node > > )
where
Node : NodeBasicInterface,
;
impl< Node > NodeCell< Node >
where
Node : NodeBasicInterface,
{
}
impl< Node > Make1< Node >
for NodeCell< Node >
where
Node : NodeBasicInterface,
{
fn make_1( src : Node ) -> Self
{
Self( Arc::new( RefCell::new( src ) ) )
}
}
impl< Node > HasId
for NodeCell< Node >
where
Node : NodeBasicInterface,
{
type Id = Node::Id;
fn id( &self ) -> Self::Id
{
self.borrow().id()
}
}
impl< Node > NodeBasicInterface
for NodeCell< Node >
where
Node : NodeBasicInterface,
{
}
impl< Node > fmt::Debug
for NodeCell< Node >
where
Node : NodeBasicInterface + fmt::Debug,
{
fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result
{
f.write_fmt( format_args!( "{:?}", self.0.borrow() ) )
}
}
impl< Node > Deref
for NodeCell< Node >
where
Node : NodeBasicInterface,
{
type Target = Arc< RefCell< Node > >;
fn deref( &self ) -> &Self::Target
{
&self.0
}
}
impl< Node > From< Arc< RefCell< Node > > >
for NodeCell< Node >
where
Node : NodeBasicInterface,
{
fn from( src : Arc< RefCell< Node > > ) -> Self
{
Self( src )
}
}
impl< Node > From< Node >
for NodeCell< Node >
where
Node : NodeBasicInterface,
{
fn from( src : Node ) -> Self
{
Self( Arc::new( RefCell::new( src ) ) )
}
}
impl< Node > PartialEq
for NodeCell< Node >
where
Node : NodeBasicInterface,
{
fn eq( &self, other : &Self ) -> bool
{
self.id() == other.id()
}
}
}
pub mod protected
{
pub use super::orphan::*;
}
pub use protected::*;
pub mod orphan
{
pub use super::exposed::*;
}
pub mod exposed
{
pub use super::prelude::*;
pub use super::private::NodeCell;
}
pub use exposed::*;
pub mod prelude
{
}