Iced filter_map Column(...) usage

⚓ Rust    📅 2026-04-09    👤 surdeus    👁️ 4      

surdeus

I am trying to build a Column based on a subset of iterated strings based on a filter:

       Column(auth.aka_iter().filter_map(|akaid| {
            match &lib.get_author(akaid) {
                None => None,
                Some(auth) => Some(row![
                    button(auth.name.as_str())
                        .on_press(|| Message::AuthorMessages(AuthorMessage::ToAKA(
                            *akaid,
                            auth.name.clone()
                        )))
                        .width(Length::FillPortion(9)),
                    button("del")
                        .on_press(|| Message::AuthorMessages(AuthorMessage::DeleteAka(*akaid)))
                        .style(iced::widget::button::danger)
                        .width(Length::FillPortion(1)),
                ].into()),
            }
        })),

Th compiler points to the row![...] call, (marking teh opening and closing '[' ']'and says:

error[E0308]: mismatched types
... above code segment ...
expected `Element<'_, {closure@...}, _, _>`, found `Element<'_, {closure@...}, ..., _>`
    |
    = note: expected struct `iced_core::element::Element<'_, {closure@src\library_window\author_gui.rs:127:35: 127:37}, _, _>`
               found struct `iced_core::element::Element<'_, {closure@src\library_window\author_gui.rs:133:35: 133:37}, Theme, _>`
    = note: no two closures, even if identical, have the same type
    = help: consider boxing your closure and/or using it as a trait object
    = note: this error originates in the macro `row` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0423]: expected function, tuple struct or tuple variant, found struct `Column`
    |
   ::: C:\Users\jmh\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\iced_widget-0.14.2\src\column.rs:35:1
    |
 35 |   pub struct Column<'a, Message, Theme = crate::Theme, Renderer = crate::Renderer>
    |   -------------------------------------------------------------------------------- `Column` defined here
   --> src\library_window\author_gui.rs:122:9
    |
122 | /         Column(auth.aka_iter().filter_map(|akaid| {
123 | |             match &lib.get_author(akaid) {
124 | |                 None => None,
125 | |                 Some(auth) => Some(row![
...   |
138 | |         })),
    | |___________^
    |
   ::: C:\Users\jmh\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\iced_widget-0.14.2\src\helpers.rs:480:1
    |
480 | / pub fn column<'a, Message, Theme, Renderer>(
481 | |     children: impl IntoIterator<Item = Element<'a, Message, Theme, Renderer>>,
482 | | ) -> Column<'a, Message, Theme, Renderer>
483 | | where
484 | |     Renderer: core::Renderer,
    | |_____________________________- similarly named function `column` defined here
    |

I don't even understand the error enough to ask a useful question.
Thank you,
Joel

6 posts - 2 participants

Read full topic

🏷️ Rust_feed