Skip to content

Commit

Permalink
gtk: Simplify types passed to ClosureExpression
Browse files Browse the repository at this point in the history
Fixes #838
  • Loading branch information
bilelmoussaoui committed Sep 5, 2022
1 parent e294fc8 commit 1d4d54b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions gtk4/src/closure_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ define_expression!(ClosureExpression, ffi::GtkClosureExpression);

impl ClosureExpression {
#[doc(alias = "gtk_closure_expression_new")]
pub fn new<R, I, E>(params: I, closure: glib::RustClosure) -> Self
pub fn new<R>(
params: impl IntoIterator<Item = impl AsRef<Expression>>,
closure: glib::RustClosure,
) -> Self
where
R: ValueType,
I: IntoIterator<Item = E>,
E: AsRef<Expression>,
{
assert_initialized_main_thread!();

Expand All @@ -32,11 +33,12 @@ impl ClosureExpression {
}

#[doc(alias = "gtk_closure_expression_new")]
pub fn with_callback<R, F, I, E>(params: I, callback: F) -> Self
pub fn with_callback<R, F>(
params: impl IntoIterator<Item = impl AsRef<Expression>>,
callback: F,
) -> Self
where
F: Fn(&[Value]) -> R + 'static,
I: IntoIterator<Item = E>,
E: AsRef<Expression>,
R: ValueType,
{
assert_initialized_main_thread!();
Expand Down
2 changes: 1 addition & 1 deletion gtk4/src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Expression {
where
R: glib::value::ValueType,
{
crate::ClosureExpression::new::<R, _, _>(&[self], closure)
crate::ClosureExpression::new::<R>(&[self], closure)
}

// rustdoc-stripper-ignore-next
Expand Down

0 comments on commit 1d4d54b

Please sign in to comment.