From 594a59bb08c1f297f86363558cd512eecf255f6b Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Thu, 24 Oct 2024 15:41:31 +0200 Subject: [PATCH] Add a hello world example --- examples/hello_world/Cargo.toml | 16 ++++++++++++++++ examples/hello_world/src/main.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 examples/hello_world/Cargo.toml create mode 100644 examples/hello_world/src/main.rs diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml new file mode 100644 index 0000000000..124a5ea549 --- /dev/null +++ b/examples/hello_world/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "hello_world" +version.workspace = true +authors = ["Dominic Clifton "] +edition.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true +rust-version.workspace = true + +[dependencies] +iced.workspace = true +iced.features = ["image", "debug"] + +[lints] +workspace = true diff --git a/examples/hello_world/src/main.rs b/examples/hello_world/src/main.rs new file mode 100644 index 0000000000..b92517bdcf --- /dev/null +++ b/examples/hello_world/src/main.rs @@ -0,0 +1,31 @@ +//! Hello world example +use iced::widget::{ + text +}; +use iced::{Element, Task }; + +/// entry point +pub fn main() -> iced::Result { + iced::run("Window title", HelloWorld::update, HelloWorld::view) +} + +#[derive(Debug)] +#[allow(dead_code)] +enum Message { + None +} + +#[derive(Default)] +struct HelloWorld {} + +impl HelloWorld { + fn update(&mut self, _message: Message) -> Task { + Task::none() + } + + fn view(&self) -> Element<'_, Message> { + let text = text("hello world"); + + text.into() + } +} \ No newline at end of file