uniffi-rs
uniffi-rs copied to clipboard
Is there a way to use `impl Into<T>` in function arguments?
trafficstars
I am trying to utilize the Into trait in my function, however I encounter an error like this (the new function mentioned here is an #[uniffi::constructor]:
error[E0562]: `impl Trait` is not allowed in paths
--> config.rs:23:23
|
23 | pub fn new(data_dir: impl Into<PathBuf>, cache_dir: impl Into<PathBuf>) -> Self {
| ^^^^^^^^^^^^^^^^^
|
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
Is there a reason why this isn't working, and are there any ways I can make it work?
It can't really work in general, because the signature exposed by the bindings needs to be one of the "primitive" types for that language - ie, something needs to know that this would translate to "String" on the foreign side. I guess it might be possible to support some "well known" traits though.
I agree. That would benefit the developer experience greatly.