Skip to content

Commit

Permalink
also vec refs
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-book2 authored Oct 12, 2023
1 parent 45357b3 commit b53ea2e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/conv/to_ocaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ where
}
}

unsafe impl<A, OCamlA: 'static> ToOCaml<OCamlList<OCamlA>> for &Vec<A>
where
for<'a> &'a A: ToOCaml<OCamlA>,
{
fn to_ocaml<'a>(self, cr: &'a mut OCamlRuntime) -> OCaml<'a, OCamlList<OCamlA>> {
let mut result = BoxRoot::new(OCaml::nil());
for elt in self.iter().rev() {
let ov = elt.to_boxroot(cr);
let cons = alloc_cons(cr, &ov, &result);
result.keep(cons);
}
cr.get(&result)
}
}

unsafe impl<A, OCamlA: 'static> ToOCaml<OCamlList<OCamlA>> for Vec<A>
where
A: ToOCaml<OCamlA>,
Expand Down

0 comments on commit b53ea2e

Please sign in to comment.