Skip to content

Commit

Permalink
add conversion for json ld types to vec string
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Tate <[email protected]>
  • Loading branch information
Ryanmtate committed Nov 13, 2024
1 parent 2701a79 commit 261c66f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/json-ld/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,21 @@ impl<'a> serde::Serialize for JsonLdTypes<'a> {
}
}

impl<'a> From<JsonLdTypes<'a>> for Vec<String> {
fn from(value: JsonLdTypes<'a>) -> Self {
let mut vec: Vec<String> = Vec::with_capacity(value.len());
vec.extend_from_slice(
&value
.static_
.into_iter()
.map(ToString::to_string)
.collect::<Vec<String>>(),
);
vec.extend(value.non_static.into_owned());
vec
}
}

pub struct WithContext<T> {
pub context: Option<json_ld::syntax::Context>,
pub value: T,
Expand Down

0 comments on commit 261c66f

Please sign in to comment.