pub struct Handle { /* private fields */ }Expand description
Handle represents a node in the forest. A handle will contribute to the reference count of the node.
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn is_connected(&self, other: &Self) -> bool
pub fn is_connected(&self, other: &Self) -> bool
Check if two nodes are connected. A node is connected to itself. This operation is O(log n).
§Examples
use dynforest::Handle;
let a = Handle::new();
let b = Handle::new();
assert!(!a.is_connected(&b));
let _conn = a.connect(&b);
assert!(a.is_connected(&b));Sourcepub unsafe fn connect_unchecked(&self, other: &Self) -> Connection
pub unsafe fn connect_unchecked(&self, other: &Self) -> Connection
Connect two nodes without checking if they are already connected.
§Safety
The caller must ensure that the two handles are not connected.
Sourcepub fn connect(&self, other: &Self) -> Option<Connection>
pub fn connect(&self, other: &Self) -> Option<Connection>
Connect two nodes.
Return None if they are already connected.
A node is always connected to itself.
This operation is O(log n).
§Examples
use dynforest::Handle;
let a = Handle::new();
let b = Handle::new();
let conn1 = a.connect(&b);
assert!(conn1.is_some());
assert!(a.is_connected(&b));
assert!(b.is_connected(&a));
let c = Handle::new();
let conn2 = b.connect(&c);
assert!(conn2.is_some());
assert!(a.is_connected(&c));
// a and c are already connected
let conn3 = a.connect(&c);
assert!(conn3.is_none());Trait Implementations§
impl Eq for Handle
Auto Trait Implementations§
impl Freeze for Handle
impl !RefUnwindSafe for Handle
impl !Send for Handle
impl !Sync for Handle
impl Unpin for Handle
impl !UnwindSafe for Handle
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