Running the example from README.md: "cannot find function `run` in crate `iced`"
orsinium opened this issue · 6 comments
orsinium commented
Is there an existing issue for this?
- I have searched the existing issues.
Is this issue related to iced?
- My hardware is compatible and my graphics drivers are up-to-date.
What happened?
error[E0425]: cannot find function `run` in crate `iced`
--> firefly-emulator/src/main.rs:42:11
|
42 | iced::run("A cool counter", Counter::update, Counter::view)
| ^^^ not found in `iced`
|
help: consider importing this function
|
12 + use iced::subscription::run;
|
help: if you import `run`, refer to it directly
|
42 - iced::run("A cool counter", Counter::update, Counter::view)
42 + run("A cool counter", Counter::update, Counter::view)
|
For more information about this error, try `rustc --explain E0425`.
error: could not compile `firefly-emulator` (bin "firefly-emulator") due to 1 previous error
Code:
#[derive(Default)]
struct Counter {
value: i32,
}
#[derive(Debug, Clone, Copy)]
pub enum Message {
Increment,
Decrement,
}
use iced::widget::{button, column, text, Column};
impl Counter {
pub fn view(&self) -> Column<Message> {
// We use a column: a simple vertical layout
column![
// The increment button. We tell it to produce an
// `Increment` message when pressed
button("+").on_press(Message::Increment),
// We show the value of the counter here
text(self.value).size(50),
// The decrement button. We tell it to produce a
// `Decrement` message when pressed
button("-").on_press(Message::Decrement),
]
}
pub fn update(&mut self, message: Message) {
match message {
Message::Increment => {
self.value += 1;
}
Message::Decrement => {
self.value -= 1;
}
}
}
}
fn main() -> iced::Result {
iced::run("A cool counter", Counter::update, Counter::view)
}
What is the expected behavior?
Expected to compile.
Version
crates.io release
Operating System
Linux
Do you have any log output?
No response
JL710 commented
The issue is that you are trying to use the new Program Api. Since this is new, it is not in any crates.io release.
You can fix it, by switching to the master branch or using the old Api (example in docs.rs or 0.12.1 tag README.md).
orsinium commented
Clear, thank you.
pelva commented
So ,The README currently suggests : iced = "0.12" is wrong