Clean up some unnecessary references
This commit is contained in:
parent
2ceccbf38d
commit
c2e78d7c54
|
@ -27,7 +27,7 @@ impl<T> Tree<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use a breadth-first-search pattern to find a node, returning the node if found.
|
/// Use a breadth-first-search pattern to find a node, returning the node if found.
|
||||||
pub fn find_bfs<'a, F>(&'a self, op: F) -> Option<Node<T>>
|
pub fn find_bfs<F>(&self, op: F) -> Option<Node<T>>
|
||||||
where
|
where
|
||||||
F: FnOnce(&T) -> bool + Copy,
|
F: FnOnce(&T) -> bool + Copy,
|
||||||
{
|
{
|
||||||
|
@ -84,14 +84,15 @@ impl<T> Node<T> {
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
// I am copying the value because I don't have a mechanism for keeping the borrow ref active.
|
/// Immutably retrieve the data in this node.
|
||||||
// My next step is to figure out how to keep the borrow ref active so that I don't have to
|
pub fn value<'a>(&self) -> Ref<T> {
|
||||||
// clone the item. Then I could drop the Clone constraint.
|
// Ref::map is not actually a member function. I don't know why this was done, other than
|
||||||
pub fn value<'a>(&'a self) -> Ref<T> {
|
// maybe to avoid conflicting with other `map` declarations. Why that is necessary when
|
||||||
|
// Option::map exists as a member, I don't know.
|
||||||
Ref::map(self.0.borrow(), |v| &v.value)
|
Ref::map(self.0.borrow(), |v| &v.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn children<'a>(&'a self) -> Ref<Vec<Node<T>>> {
|
pub fn children<'a>(&self) -> Ref<Vec<Node<T>>> {
|
||||||
Ref::map(self.0.borrow(), |v| &v.children)
|
Ref::map(self.0.borrow(), |v| &v.children)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue