MCPcopy Create free account
hub / github.com/douchuan/algorithm / sibling

Method sibling

src/tree/binary/node.rs:89–101  ·  view source on GitHub ↗
(node: Option<NonNull<Self>>)

Source from the content-addressed store, hash-verified

87 }
88
89 pub fn sibling(node: Option<NonNull<Self>>) -> Option<NonNull<Self>> {
90 unsafe {
91 node.and_then(|node| {
92 node.as_ref().parent.and_then(|parent| {
93 if parent.as_ref().left == Some(node) {
94 parent.as_ref().right
95 } else {
96 parent.as_ref().left
97 }
98 })
99 })
100 }
101 }
102
103 pub fn uncle(node: Option<NonNull<Self>>) -> Option<NonNull<Self>> {
104 unsafe {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected