iced Hello World

Iced looks like a decent toolkit for writing desktop apps. I wanted the bog-simplest program I could start with. I think this is it. Based on a few tutorials I have found around.

After running cargo init hello I have the standard directory/file layout:

Cargo.toml
src/main.rs
.gitignore

I want to minimize dependencies (to start) so my Cargot.toml is simply:

[package]
name = "hello"
version = "0.1.0"
edition = "2024"

[dependencies]
iced = "0.14.0"

My main.rs:

use iced::{Element};
use iced::widget::{text};
 
pub fn main() -> iced::Result{
    iced::run(Hello::update, Hello::view)
}
 
pub enum Message {
}
 
struct Hello;
 
impl Hello {
 
    fn new () ->; Self {
        Hello{}
    }
 
    fn update(&mut self, _message: Message) {
 
    }
 
    fn view(&self) -> Element<'_, Message> {
                text!("Hello, World").into()
    }
 
}
 
impl Default for Hello {
    fn default() -> Self{
        Self::new()
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.