[bindings] Add support for `Option<T>` where T is a mapped trait
authorMatt Corallo <git@bluematt.me>
Fri, 25 Sep 2020 16:12:03 +0000 (12:12 -0400)
committerMatt Corallo <git@bluematt.me>
Mon, 12 Oct 2020 16:17:26 +0000 (12:17 -0400)
commit0719f9af00d3669302cec07f67c8d6980e64ed0b
treeb2f84e89d6275fcf323df9a340aeb2b943ebffde
parent36e732879ad68b5e13d8a6e33196cb1263f0cf2a
[bindings] Add support for `Option<T>` where T is a mapped trait

When mapping an `Option<T>` where T is a mapped trait, we need to
move out of the `*mut T`, however the current generation results in
a `*const T` and a conversion that just takes a reference to the
pointed-to object. This is because the only place this code was
previously used was for slices, which *do* need a reference.

Additionally, we need to know how to convert `Option` containers
which do not contain an opaque type.

Sadly, the easiest way to get the desired result is to add another
special case in container mapping, keeping the current behavior for
slices, but moving out of the pointed-to object for other types.
c-bindings-gen/src/types.rs