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

Fix broken grid generic parameters #227

Merged

Conversation

Exidex
Copy link
Contributor

@Exidex Exidex commented Apr 2, 2024

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())
}

Copy link
Collaborator

@genusistimelord genusistimelord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

@genusistimelord genusistimelord merged commit 132c854 into iced-rs:main Apr 2, 2024
2 checks passed
@Exidex Exidex deleted the fix-grid-fn-signature branch April 6, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants