wolf4ood/gremlin-rs

Implement ToGValue for Vec<GValue>?

Closed this issue · 1 comments

I wanted to write something like:

let ids_from_somewhere = vec![1,2,3];
let converted_ids:Vec<GValue> = ids_from_somewhere
  .into_iter()
  .map(|x| x.into())
  .collect();

let q = "g.V(ids_of_vertices)";
let params: &[(&str, &dyn ToGValue)] = &[("ids_of_vertices", &converted_ids)];
graph.execute(q, params)//....and so forth

But it kept saying there wasn't an implement of ToGValue for Vec<GValue> which surprised me.

Adding this:

impl ToGValue for Vec<GValue> {
    fn to_gvalue(&self) -> GValue {
        GValue::List(List::new(self.clone()))
    }
}

to conversion.rs addressed that issue and it seems to work, but I wondered if this omission was intentional? Otherwise I'd like to open a PR to add it.

Hi @criminosis i guess it's not intentional, It make sense to have it.
I PR is more than welcome :)