Skip to content
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

ClosureExpression::new asks for all three generic types #838

Closed
zecakeh opened this issue Jan 19, 2022 · 4 comments · Fixed by #839 or #1118
Closed

ClosureExpression::new asks for all three generic types #838

zecakeh opened this issue Jan 19, 2022 · 4 comments · Fixed by #839 or #1118
Labels
enhancement New feature or request gtk
Milestone

Comments

@zecakeh
Copy link
Contributor

zecakeh commented Jan 19, 2022

A closure expression has to be declared like that:

gtk::ClosureExpression::new::<bool, _, _>(
    &[a_expr],
    closure!(|_: Option<Object>, a: bool| { !a }),
)

One with no parameters must be declared like that:

gtk::ClosureExpression::new::<String, &[gtk::Expression], _>(
    &[],
    closure!(|member: Option<Member>| { member.map(search_string).unwrap_or_default() }),
)

It would be great if at most we only had to annotate the ValueType, like in chain_closure. But if the closure! return type could be used for the ValueType, that would be even better.

@zecakeh zecakeh added the enhancement New feature or request label Jan 19, 2022
@bilelmoussaoui
Copy link
Member

@zecakeh I don't think there is a simple way to figure out the return type of a RustClosure, it all happens at runtime

@sdroege
Copy link
Member

sdroege commented Jan 19, 2022

The types of the glib::Closure created by the closure! macro are unfortunately not part of the type. Doing this would require making the glib::RustClosure type generic at least. It should be doable but is a bit of work.

@zecakeh
Copy link
Contributor Author

zecakeh commented Jan 19, 2022

No problem. Just wishful thinking :)

@bilelmoussaoui
Copy link
Member

This can be fixed now as we have bumped the minimum rust version to 1.63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gtk
Projects
None yet
3 participants