uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

Support for `Option<&T>`

Open oguzkocer opened this issue 8 months ago • 1 comments

According to the documentation(source), Option<&T> is supported by proc macro:

#[uniffi::export]
fn process_data(a: &MyRecord, b: &MyEnum, c: Option<&MyRecord>) {}

However, this seems to result in the following error:

| fn process_data(_a: &MyRecord, _b: &MyEnum, _c: Option<&MyRecord>) {}
|                                                 ^^^^^^^^^^^^^^^^^ the trait `uniffi::TypeId<UniFfiTag>` is not implemented for `&MyRecord`, which is required by `Option<&MyRecord>: uniffi::TypeId<UniFfiTag>`

Here is a demo project that demonstrates this. Hopefully I am missing something, but if not, would it be possible to add support for this?

The alternative at the moment is to use &Option<T>, but that has completely different semantics to Option<&T>.

oguzkocer avatar Jun 12 '24 00:06 oguzkocer