Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Application
✓ use iced::Application;
A simple counter GUI application with increment/decrement buttons.
use iced::{Application, Settings, Element, executor, Command, Theme};
struct Counter { value: i32 }
#[derive(Debug, Clone)]
enum Message { Increment, Decrement }
impl Application for Counter {
type Executor = executor::Default;
type Message = Message;
type Theme = Theme;
type Flags = ();
fn new(_flags: ()) -> (Counter, Command<Message>) {
(Counter { value: 0 }, Command::none())
}
fn title(&self) -> String {
"Counter".to_string()
}
fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::Increment => self.value += 1,
Message::Decrement => self.value -= 1,
}
Command::none()
}
fn view(&self) -> Element<Message> {
use iced::widget::{button, column, text};
column![
button("+").on_press(Message::Increment),
text(self.value),
button("-").on_press(Message::Decrement),
].into()
}
}
fn main() -> iced::Result {
Counter::run(Settings::default())
}
Upgrade
Version history
0.14.0latest on crates.io
Audit
Dependencies
No dependency data recorded yet.