feat: Node::maybe_object

This commit is contained in:
əlemi 2024-03-21 01:10:04 +01:00
parent 45c5ea69a6
commit 59e8b298f5
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -110,8 +110,15 @@ impl Node<serde_json::Value>{
}
}
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<impl super::Base>) -> Self {
match x {
Some(x) => Node::Object(Box::new(x.underlying_json_object())),
None => Node::Empty,
}
}
pub fn array(x: Vec<impl super::Base>) -> Self {