iced-template: factor out Element, explicit Error

the type alias Element is quite useful for defining subfunctions for view
and it also helps to not pull unnecessary things into scope
This commit is contained in:
electria 2026-08-16 14:26:32 -07:00
commit 6d7c1bf7fd
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -1,4 +1,6 @@
use iced::{Color, Element, Renderer, Task, Theme, application, theme, widget};
use iced::{Color, Task, application, theme, widget};
type Element<'a> = iced::Element<'a, Message, iced::Theme, iced::Renderer>;
enum Message {}
@ -11,12 +13,12 @@ impl State {
fn update(&mut self, message: Message) -> Task<Message> {
Task::none()
}
fn view(&self) -> Element<'_, Message, Theme, Renderer> {
fn view(&self) -> Element<'_> {
widget::text("hiiiiiii").into()
}
}
pub fn run() -> Result<(), impl std::error::Error> {
pub fn run() -> Result<(), iced::Error> {
application(State::new, State::update, State::view)
.theme(theme::Theme::custom(
"high-contrast-dark",