iced-rs / iced_aw

Additional widgets for the Iced GUI library
MIT License
467 stars 110 forks source link

Fix broken grid generic parameters #227

Closed Exidex closed 7 months ago

Exidex commented 7 months ago

Fixes

error[E0277]: the trait bound `Theme: iced::advanced::Renderer` is not satisfied
   --> src/main.rs:34:40
    |
34  |         let content: Element<_> = grid(rows)
    |                                   ---- ^^^^ the trait `iced::advanced::Renderer` is not implemented for `Theme`
    |                                   |
    |                                   required by a bound introduced by this call
    |
    = help: the following other types implement trait `iced::advanced::Renderer`:
              iced::Renderer
              iced::advanced::iced_graphics::Renderer<B>
              iced::advanced::renderer::Null
note: required by a bound in `grid`
   --> /home/exidex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_aw-0.8.0/src/native/helpers.rs:268:15
    |
264 | pub fn grid<Message, Renderer>(
    |        ---- required by a bound in this function
...
268 |     Renderer: renderer::Renderer,
    |               ^^^^^^^^^^^^^^^^^^ required by this bound in `grid`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `text_scrollable_bug` (bin "text_scrollable_bug") due to 1 previous error

with following code

use iced::{Element, Sandbox, Settings};
use iced::widget::text;
use iced_aw::GridRow;
use iced_aw::helpers::{grid, grid_row};

struct App;

impl Sandbox for App {
    type Message = ();

    fn new() -> Self {
        Self
    }

    fn title(&self) -> String {
        "Title".into()
    }

    fn update(&mut self, _: Self::Message) {}

    fn view(&self) -> Element<'_, Self::Message> {
        let rows = (0..10)
            .map(|row| {
                let vec = (0..10)
                    .map(|col| {
                        text(format!("{col} {row}")).into()
                    })
                    .collect::<Vec<Element<_>>>();

                grid_row(vec)
            })
            .collect::<Vec<GridRow<_>>>();

        let content: Element<_> = grid(rows)
            .into();

        content
    }
}

fn main() -> iced::Result {
    App::run(Settings::default())
}