Reference
Runtime Function - run
Detailed guidance for iced::run.
Runtime Function - iced::run
Authoritative source: ref/doc/iced/fn.run.html.
# Verified signature
rust
pub fn run<State, Message, Theme, Renderer>( update: impl UpdateFn<State, Message> + 'static, view: impl for<'a> ViewFn<'a, State, Message, Theme, Renderer> + 'static, ) -> Result where State: Default + 'static, Message: Send + MaybeDebug + MaybeClone + 'static, Theme: Base + 'static, Renderer: Renderer + 'static,
# Use this when...
- You want the shortest path to a working app.
State: Defaultis acceptable.- You do not need heavy runtime builder configuration yet.
# Minimal example
rust
pub fn main() -> iced::Result { iced::run(App::update, App::view) }
# How it works
run wires your update and view functions into Iced's event loop. User input creates messages, update mutates state, and view rebuilds widgets from that state.
# Common patterns
rust
use iced::widget::{button, column, text}; #[derive(Default)] struct App { value: u64 } #[derive(Debug, Clone)] enum Message { Increment } impl App { fn update(&mut self, message: Message) { match message { Message::Increment => self.value += 1 } } fn view(&self) -> iced::widget::Column<'_, Message> { column![text(self.value), button("+").on_press(Message::Increment)] } }
# Gotchas / tips
runrequires default-initializable state; useapplicationwhen bootstrapping is custom.- Keep
viewside-effect free; perform async work via tasks inupdate. - If startup config grows, migrate to
iced::application(...)rather than overloading state defaults.
# Example references
ref/examples/counter/src/main.rsref/examples/progress_bar/src/main.rsref/examples/exit/src/main.rs