-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust library requires type F
even when no adapter is passed
#93
Comments
You are right. This is indeed a known problem and a fix is appreciated. But I don't understand how the workaround fixes the problem. Isn't it just moving the type definition. We still need to give a type. If you see in the example let embed_data = embed_webpage(
url,
&embeder,
Some(&embed_config),
None::<fn(Vec<EmbedData>)>,
)
.await
.unwrap()
.unwrap(); But feel free to open a PR if you figure out a cleaner solution. |
Yeah the workaround I mentioned was how I got around the type error, not really how to avoid the issue in the library 😅 |
Off the back of #92, I created |
Thanks for pointing me in the right direction. It doesn't work as it is, but making the following change removes the requirement for a type definition in the function call. I need to see if it works well with PyO3, though. - adapter: Option<impl FnOnce(Vec<EmbedData>)>
+ adapter: Option<Box<dyn FnOnce(Vec<EmbedData>)>> |
Describe the bug
Embed functions like
embed_website
require a generic typeF
to be specified. This type is the type for the callbackadapter
.However,
adapter
is optional and we can therefore passNone
. This leads to a type resolution problem though, sinceF
is required.It is possible to work around this, but it's not super clean - I ended up with
Expected behavior
I should be able to call
embed_webpage
without a type, especially if I'm not passing an adapter.Screenshots
The text was updated successfully, but these errors were encountered: