It's a little awkward to turn an iterator of Element into a List right now. You must collect as a Sequence or Vec<Element> and then convert to a List. E.g.:
fn json_to_ion(value: serde_json::Value) -> Element {
match value {
// ...
Value::Array(values) => List(
values
.into_iter()
.map(|v| json_to_ion(v))
.collect::<Sequence>()
)
.into(),
}
}
Since Sequence already implements FromIterator<Element>, why not Sexp and List? It would be nice to collect directly as a List or Sexp`. E.g.:
fn json_to_ion(value: serde_json::Value) -> Element {
match value {
// ...
Value::Array(values) => values
.into_iter()
.map(|v| json_to_ion(v))
.collect::<List>()
.into(),
}
}
It's a little awkward to turn an iterator of
Element
into aList
right now. You must collect as aSequence
orVec<Element>
and then convert to aList
. E.g.:Since
Sequence
already implementsFromIterator<Element>
, why notSexp
andList
? It would be nice to collect directly as aList
or Sexp`. E.g.: