Iced - Unable to create a grid widget

I am trying to learn layout in iced and ran across the grid widget. I would like to use it but am having a problem. In the example below I get the error "consider specifying the generic arguments '::<Message, Theme, Renderer>`. I do not know how to do this. Any input will be appreciated.

widget::grid::Grid::from_vec(
    // consider specifying the generic arguments: `::<Message, Theme, Renderer>`
    vec![       
        widget::text("Cell 1:1").into(),
        widget::text("Cell 1:2").into(),
        widget::text("Cell 2:1").into(),
        widget::text("Cell 2:2").into(), 
    ]  
)
.columns(2);

Are you actually returning the widget/using the widget in your view function? The compiler will often struggle to infer the Message type, etc, unless you actually use the widget.

Try using the grid! macro, rather than Grid::from_vec, for slightly cleaner code (it will allow you to remove all the .into() calls, for starters).

you can do

widget::grid::Grid::from_vec::<Message, Theme, Renderer>(
    vec![       
        widget::text("Cell 1:1").into(),
        widget::text("Cell 1:2").into(),
        widget::text("Cell 2:1").into(),
        widget::text("Cell 2:2").into(), 
    ]  
)
.columns(2);

with any types allowed there although it's more likely that these parameters depend on the object using the widget in which case just using it is going to contrain the type enough so you don't have to specify it

Thank you for the replies. I could not get either suggestion to work. In hindsight I should have included more code. The container of code below is currently being used in a view and works. I read about the grid widget and thought this might be a better solution. My goal is to replace all of the contents within the container with a grid. Below the container are my two attempts at a grid with the errors shown in the code as a comment. I clearly do not understand the required grid syntax.

        widget::container(
            widget::row![
                widget::column![
                    widget::text("Records Read:").size(20.0),
                    widget::text("Records Inserted:").size(20.0),
                ] // end column
                .width(Length::FillPortion(1))
                .align_x(Horizontal::Right)
                .padding(padding::right(5))
                .spacing(15),

                widget::column![
                    widget::text(rec_read.to_string()).size(20.0),
                    widget::text(rec_inserted.to_string()).size(20.0),
                ]
                .width(Length::FillPortion(1))
                .align_x(Horizontal::Left)
                .padding(padding::left(5))
                .spacing(15),

            ] // end of row
            .width(Length::Fill) 
        )
        .height(Length::FillPortion(container3))
        .align_y(Vertical::Center), 

// end of container

    widget::grid!(
        widget::text("Cell 1:1"),
        // error type annotations needed - error is for the line directly above
        widget::text("Cell 1:2"),
        widget::text("Cell 2:1"),
        widget::text("Cell 2:2"),        
    ).columns(2);

    widget::grid::Grid::from_vec::<Message, iced::Theme, iced::Renderer>(
        // error takes 0 generidc parameters but found 3 - error is for the line directly above
        vec![       
            widget::text("Cell 1:1").into(),
            widget::text("Cell 1:2").into(),
            widget::text("Cell 2:1").into(),
            widget::text("Cell 2:2").into(),
        ]  
    ) 
    .columns(2);

After lots of additional reading and a few tests I found the solution. Instead of using a vector I used the push method on a new Grid. The best thing about this approach is that you are suppose to be able to add elements dynamically but have not yet confirmed it. I still have to work on setting the layout to mimic the container listed above. Thank you for all the input.

Grid::new()
    .columns(2)
    .push(widget::text("Cell 1:1"))
    .push(widget::text("Cell 1:2"))
    .push(widget::text("Cell 2:1"))
    .push(widget::text("Cell 2:2"))
    .height(Length::FillPortion(2)),