feat: Node::get() returns owned object
This commit is contained in:
parent
be75ac33d1
commit
b0d8957f41
1 changed files with 5 additions and 8 deletions
|
@ -15,17 +15,14 @@ impl<T : super::Base> From<Option<T>> for Node<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T : super::Base> Node<T> {
|
impl<T : super::Base> Node<T> {
|
||||||
pub fn get(&self) -> Option<&T> {
|
pub fn get(self) -> Option<T> {
|
||||||
match self {
|
match self {
|
||||||
Node::Empty | Node::Link(_) => None,
|
Node::Empty | Node::Link(_) => None,
|
||||||
Node::Object(x) => Some(x),
|
Node::Object(x) => Some(*x),
|
||||||
Node::Array(v) => match v.iter().find_map(|x| match x {
|
Node::Array(v) => v.into_iter().find_map(|x| match x {
|
||||||
Node::Object(x) => Some(x),
|
Node::Object(x) => Some(*x),
|
||||||
_ => None,
|
_ => None,
|
||||||
}) {
|
}),
|
||||||
Some(x) => Some(x),
|
|
||||||
None => None,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue