Skip to content

Commit

Permalink
Fixes rust generated code when taking expression of void callback
Browse files Browse the repository at this point in the history
code like so:
```slint
callback foo();
if true : Button {
   clicked => {
      true ? foo() : foo();
   }
}
```

the code like foo() use the `option.map()`  to get to the parent, but then it
needs to still be wrapped in a `{...}` to convert that to a `()` expression

Fixes #5883
  • Loading branch information
ogoffart committed Aug 21, 2024
1 parent 955c519 commit e0ca9df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/compiler/generator/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1993,11 +1993,11 @@ impl MemberAccess {
MemberAccess::Direct(t) => f(t),
MemberAccess::Option(t) => {
let r = f(quote!(x));
quote!(let _ = #t.map(|x| #r);)
quote!({ let _ = #t.map(|x| #r); })
}
MemberAccess::OptionFn(opt, inner) => {
let r = f(inner);
quote!(let _ = #opt.as_ref().map(#r);)
quote!({ let _ = #opt.as_ref().map(#r); })
}
}
}
Expand Down

0 comments on commit e0ca9df

Please sign in to comment.