I’m trying to do the iced rust tutorial (from the book) but i encountered a compiling error hen i tried to make a button:
use iced::widget::button;
fn main() {
let mut counter = Counter { value: 0 };
counter.update(Message::Increment);
counter.update(Message::Increment);
counter.update(Message::Decrement);
let inc = button("+");
let dec = button("-");
}
struct Counter{
value: i64,
}
impl Counter{
fn update(&mut self, msg:Message){
match msg{
Message::Increment=>{
self.value +=1;
}
Message::Decrement=>{
self.value -=1;
}
}
}
}
enum Message{
Increment,
Decrement,
}
In particular the line let inc = button("+");
make this error:
Compiling note v0.1.0 (/home/gattolfo/Documents/rust/note)
error[E0283]: type annotations needed for `iced::widget::Button<'_, _, _, _>`
--> src/main.rs:12:7
|
12 | let inc = button("+");
| ^^^ ----------- type must be known at this point
|
= note: cannot satisfy `_: iced::widget::button::DefaultStyle`
= help: the following types implement trait `iced::widget::button::DefaultStyle`:
Theme
iced::Color
iced::widget::button::Appearance
note: required by a bound in `button`
--> /home/gattolfo/.cargo/git/checkouts/iced-f01cba4d5e61fd0a/cdb18e6/widget/src/helpers.rs:120:12
|
116 | pub fn button<'a, Message, Theme, Renderer>(
| ------ required by a bound in this function
...
120 | Theme: button::DefaultStyle + 'a,
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `button`
help: consider giving `inc` an explicit type, where the type for type parameter `Theme` is specified
|
12 | let inc: iced::widget::Button<'_, Message, Theme, Renderer> = button("+");
| ++++++++++++++++++++++++++++++++++++++++++++++++++++
For more information about this error, try `rustc --explain E0283`.
error: could not compile `note` (bin "note") due to 1 previous error
What i’m doing wrong? I’m not able to find other on the book.