iced

Function run

Source
pub fn run<State, Message, Theme, Renderer>(
    title: impl Title<State> + 'static,
    update: impl Update<State, Message> + 'static,
    view: impl for<'a> View<'a, State, Message, Theme, Renderer> + 'static,
) -> Result
where State: Default + 'static, Message: Debug + Send + 'static, Theme: Default + Base + 'static, Renderer: Renderer + 'static,
Expand description

Runs a basic iced application with default Settings given its title, update, and view logic.

This is equivalent to chaining application() with Application::run.

ยงExample

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

pub fn main() -> iced::Result {
    iced::run("A counter", update, view)
}

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

fn update(value: &mut u64, message: Message) {
    match message {
        Message::Increment => *value += 1,
    }
}

fn view(value: &u64) -> Column<Message> {
    column![
        text(value),
        button("+").on_press(Message::Increment),
    ]
}