From b0d8957f41283be37dc016a3878b481b3ef480ed Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 26 Mar 2024 00:49:42 +0100 Subject: [PATCH] feat: Node::get() returns owned object --- src/activitystream/node.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/activitystream/node.rs b/src/activitystream/node.rs index 23149b27..05cf7c1b 100644 --- a/src/activitystream/node.rs +++ b/src/activitystream/node.rs @@ -15,17 +15,14 @@ impl From> for Node { } impl Node { - pub fn get(&self) -> Option<&T> { + pub fn get(self) -> Option { match self { Node::Empty | Node::Link(_) => None, - Node::Object(x) => Some(x), - Node::Array(v) => match v.iter().find_map(|x| match x { - Node::Object(x) => Some(x), + Node::Object(x) => Some(*x), + Node::Array(v) => v.into_iter().find_map(|x| match x { + Node::Object(x) => Some(*x), _ => None, - }) { - Some(x) => Some(x), - None => None, - }, + }), } }