Skip to content

"First Steps" in docs show code that does not compile #24

Description

@MrIceman

I wanted to try out iced for my biotech project, however, when going through the docs and reimplementing example code I get following compilation error

expected `iced_core::element::Element<Message, iced_core::theme::Theme, iced_renderer::Renderer>`, but found `iced_widget::button::Button<Message, _, _>`

basically the column! macro does not like the arguments.

Image

Here's my full code

use iced::widget::{button, text, column, Column};

pub struct Counter {
    pub value: i64,
}

#[derive(Debug, Clone, Copy)]
pub enum Message {
    Increment,
    Decrement,
}

impl Counter {

    fn view(&self) -> Column<Message> {
        // The buttons
        let increment = button("+").on_press(Message::Increment);
        let decrement = button("-").on_press(Message::Decrement);

        // The number
        let counter = text(self.value);

        // The layout
        let interface = column![increment, counter, decrement];

        interface
    }

    pub fn update(&mut self, message: Message) {
        match message {
            Message::Increment => {
                println!("Incrementing counter");
                self.value += 1
            },
            Message::Decrement => self.value -= 1,
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions