wolf4ood / gremlin-rs

Gremlin Rust
Apache License 2.0
108 stars 30 forks source link

Implement ToGValue for Vec<GValue>? #134

Closed criminosis closed 3 years ago

criminosis commented 3 years ago

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.

wolf4ood commented 3 years ago

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