iced-yoda/style/src
Marien Zwart d20493c8a0
Support conversion from Fn trait to custom theme
...instead of just from function pointers.

I'm making this change not because I actually want to pass a closure,
but to make passing a single fixed function work. This commit also
simplifies the scrollable example slightly, and without the other half
of this change that simplified example fails to compile with:

```
error[E0277]: the trait bound `iced::theme::ProgressBar: From<for<'a> fn(&'a Theme) -> iced::widget::progress_bar::Appearance {progress_bar_custom_style}>` is not satisfied
   --> examples/scrollable/src/main.rs:292:28
    |
292 |                     .style(progress_bar_custom_style)
    |                      ----- ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<for<'a> fn(&'a Theme) -> iced::widget::progress_bar::Appearance {progress_bar_custom_style}>` is not implemented for `iced::theme::ProgressBar`
    |                      |
    |                      required by a bound introduced by this call
    |
    = help: the trait `From<for<'a> fn(&'a Theme) -> iced::widget::progress_bar::Appearance>` is implemented for `iced::theme::ProgressBar`
    = note: required for `for<'a> fn(&'a Theme) -> iced::widget::progress_bar::Appearance {progress_bar_custom_style}` to implement `Into<iced::theme::ProgressBar>`
note: required by a bound in `iced::widget::ProgressBar::<Renderer>::style`
   --> /home/marienz/src/iced/widget/src/progress_bar.rs:77:21
    |
77  |         style: impl Into<<Renderer::Theme as StyleSheet>::Style>,
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ProgressBar::<Renderer>::style`
```

This happens because `progress_bar_custom_style` by itself is a function
item, which is typically coerced to a function pointer when one is
needed, but not in this case. It is possible to work around this on the
caller's side, but especially since the compiler diagnostic for this is
a bit rough (see https://github.com/rust-lang/rust/issues/100116) let's
try to make it work out of the box.
2023-05-21 23:41:26 +10:00
..
theme Write documentation for iced_style 2022-11-10 01:10:28 +01:00
application.rs Write documentation for iced_style 2022-11-10 01:10:28 +01:00
button.rs Added support for gradients as background variants + other optimizations. 2023-05-11 11:13:44 -07:00
checkbox.rs Added the ability to change checkbox icon 2023-02-16 14:13:04 +01:00
container.rs Write documentation for iced_style 2022-11-10 01:10:28 +01:00
lib.rs Create iced_widget subcrate and re-organize the whole codebase 2023-03-04 05:37:11 +01:00
menu.rs Write documentation for iced_style 2022-11-10 01:10:28 +01:00
pane_grid.rs Change name of hovered region style struct, reorder lines & export Appearance 2023-05-19 12:02:39 +01:00
pick_list.rs Rename pick_list::AccessoryContent to Handle 2022-12-14 03:31:12 +01:00
progress_bar.rs Write documentation for iced_style 2022-11-10 01:10:28 +01:00
radio.rs Write documentation for iced_style 2022-11-10 01:10:28 +01:00
rule.rs Write documentation for iced_style 2022-11-10 01:10:28 +01:00
scrollable.rs Fix inconsistency in default implementation of scrollable::StyleSheet 2023-03-27 15:57:51 +02:00
slider.rs Remove border_radius support for slider::Rail 2023-04-13 05:53:40 +02:00
svg.rs Remove appearance from Handle 2022-12-06 04:34:00 +01:00
text_input.rs Introduce disabled state for TextInput 2023-04-12 03:55:18 +02:00
theme.rs Support conversion from Fn trait to custom theme 2023-05-21 23:41:26 +10:00
toggler.rs Write documentation for iced_style 2022-11-10 01:10:28 +01:00