From 59e8b298f5475ce43156470e40ad8bb9c9c43926 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 21 Mar 2024 01:10:04 +0100 Subject: [PATCH] feat: Node::maybe_object --- src/activitystream/node.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/activitystream/node.rs b/src/activitystream/node.rs index 418fd87e..faf46670 100644 --- a/src/activitystream/node.rs +++ b/src/activitystream/node.rs @@ -110,8 +110,15 @@ impl Node{ } } - pub fn object(x: serde_json::Value) -> Self { - Node::Object(Box::new(x)) + pub fn object(x: impl super::Base) -> Self { + Node::Object(Box::new(x.underlying_json_object())) + } + + pub fn maybe_object(x: Option) -> Self { + match x { + Some(x) => Node::Object(Box::new(x.underlying_json_object())), + None => Node::Empty, + } } pub fn array(x: Vec) -> Self {