pub struct NodeRef(pub NodeId);
Expand description
An identifier for a node in the three storage
Tuple Fields§
§0: NodeId
Methods from Deref<Target = NodeId>§
pub fn debug_pretty_print<'a, T>(
&'a self,
arena: &'a Arena<T>,
) -> DebugPrettyPrint<'a, T>
pub fn debug_pretty_print<'a, T>( &'a self, arena: &'a Arena<T>, ) -> DebugPrettyPrint<'a, T>
Returns the pretty-printable proxy object to the node and descendants.
§(No) guarantees
This is provided mainly for debugging purpose. Node that the output format is not guaranteed to be stable, and any format changes won’t be considered as breaking changes.
§Examples
// arena
// `-- "root"
// |-- "0"
// | |-- "0\n0"
// | `-- "0\n1"
// |-- "1"
// `-- "2"
// `-- "2\n0"
// `-- "2\n0\n0"
let printable = root.debug_pretty_print(&arena);
let expected_debug = r#""root"
|-- "0"
| |-- "0\n0"
| `-- "0\n1"
|-- "1"
`-- "2"
`-- "2\n0"
`-- "2\n0\n0""#;
assert_eq!(format!("{:?}", printable), expected_debug);
let expected_display = r#"root
|-- 0
| |-- 0
| | 0
| `-- 0
| 1
|-- 1
`-- 2
`-- 2
0
`-- 2
0
0"#;
assert_eq!(printable.to_string(), expected_display);
Alternate styles ({:#?}
and {:#}
) are also supported.
// arena
// `-- Ok(42)
// `-- Err("err")
let printable = root.debug_pretty_print(&arena);
let expected_debug = r#"Ok(42)
`-- Err("err")"#;
assert_eq!(format!("{:?}", printable), expected_debug);
let expected_debug_alternate = r#"Ok(
42,
)
`-- Err(
"err",
)"#;
assert_eq!(format!("{:#?}", printable), expected_debug_alternate);
Trait Implementations§
source§impl Ord for NodeRef
impl Ord for NodeRef
source§impl PartialOrd for NodeRef
impl PartialOrd for NodeRef
impl Copy for NodeRef
impl Eq for NodeRef
impl StructuralPartialEq for NodeRef
Auto Trait Implementations§
impl Freeze for NodeRef
impl RefUnwindSafe for NodeRef
impl Send for NodeRef
impl Sync for NodeRef
impl Unpin for NodeRef
impl UnwindSafe for NodeRef
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more