cl-structures: Tree cleanup
This commit is contained in:
parent
9f9a21b4c3
commit
66c29d601c
@ -158,6 +158,9 @@ impl<T> Node<T> {
|
|||||||
std::mem::replace(&mut self.value, value)
|
std::mem::replace(&mut self.value, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn parent(&self) -> Option<Ref<T>> {
|
||||||
|
self.parent
|
||||||
|
}
|
||||||
pub fn children(&self) -> &[Ref<T>] {
|
pub fn children(&self) -> &[Ref<T>] {
|
||||||
&self.children
|
&self.children
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ use std::{marker::PhantomData, num::NonZeroUsize};
|
|||||||
pub struct Ref<T: ?Sized>(NonZeroUsize, PhantomData<T>);
|
pub struct Ref<T: ?Sized>(NonZeroUsize, PhantomData<T>);
|
||||||
|
|
||||||
impl<T: ?Sized> Ref<T> {
|
impl<T: ?Sized> Ref<T> {
|
||||||
/// Constructs a new [TreeRef] with the given index
|
/// Constructs a new [Ref] with the given index
|
||||||
pub fn new_unchecked(index: usize) -> Self {
|
pub fn new_unchecked(index: usize) -> Self {
|
||||||
// Safety: index cannot be zero because we use saturating addition on unsigned type.
|
// Safety: index cannot be zero because we use saturating addition on unsigned type.
|
||||||
Self(
|
Self(
|
||||||
|
Loading…
Reference in New Issue
Block a user