Closed fbq closed 7 months ago
I prefer option 1, since that way is simpler and can be better documented. People who want to do what you described probably will not reach for Option<T>
on their first try, but rather do the null check manually.
try_from_foreign
(option 1 here) is now in rust-next
.
Currently
ForeignOwnable::from_foreign()
only works for non-null pointers for the existingimpl
s (e.g.Box
,Arc
). It may create a few duplicate code like:see this patch for example.
It's better if we have a function:
*const void
->Option<ForeignOwnable>
, which can handle null pointer cases. There are at least two ways I can think of:try_from_foreign()
function inForeignOwnable
trait:impl ForeignOwnable
forOption<T: ForeignOwnable>
:Of course, there could be better ideas ;-)