From 0e8c3fe30fd7c9a9ff54d2f6d75324575df5511a Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Thu, 3 Oct 2024 22:27:25 -0500 Subject: [PATCH 1/2] chore: remove once_cell dependency --- Cargo.lock | 9 --- Cargo.toml | 1 - core/Cargo.toml | 1 - core/src/theme.rs | 6 +- core/src/theme/palette.rs | 91 +++++++++++++------------ examples/loading_spinners/Cargo.toml | 1 - examples/loading_spinners/src/easing.rs | 15 ++-- examples/scrollable/Cargo.toml | 2 - examples/scrollable/src/main.rs | 7 +- examples/visible_bounds/Cargo.toml | 2 - examples/visible_bounds/src/main.rs | 10 +-- examples/websocket/Cargo.toml | 1 - examples/websocket/src/main.rs | 6 +- graphics/Cargo.toml | 1 - graphics/src/text.rs | 5 +- highlighter/Cargo.toml | 1 - highlighter/src/lib.rs | 10 +-- wgpu/Cargo.toml | 1 - widget/Cargo.toml | 1 - widget/src/helpers.rs | 5 +- 20 files changed, 80 insertions(+), 96 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 85fab142e4..d1f4aacaed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2435,7 +2435,6 @@ dependencies = [ "glam", "log", "num-traits", - "once_cell", "palette", "rustc-hash 2.1.0", "smol_str", @@ -2472,7 +2471,6 @@ dependencies = [ "kamadak-exif", "log", "lyon_path", - "once_cell", "raw-window-handle 0.6.2", "rustc-hash 2.1.0", "thiserror 1.0.69", @@ -2484,7 +2482,6 @@ name = "iced_highlighter" version = "0.14.0-dev" dependencies = [ "iced_core", - "once_cell", "syntect", ] @@ -2549,7 +2546,6 @@ dependencies = [ "iced_graphics", "log", "lyon", - "once_cell", "resvg", "rustc-hash 2.1.0", "thiserror 1.0.69", @@ -2564,7 +2560,6 @@ dependencies = [ "iced_renderer", "iced_runtime", "num-traits", - "once_cell", "ouroboros", "pulldown-cmark", "qrcode", @@ -3066,7 +3061,6 @@ version = "0.1.0" dependencies = [ "iced", "lyon_algorithms", - "once_cell", ] [[package]] @@ -4738,7 +4732,6 @@ name = "scrollable" version = "0.1.0" dependencies = [ "iced", - "once_cell", ] [[package]] @@ -5936,7 +5929,6 @@ name = "visible_bounds" version = "0.1.0" dependencies = [ "iced", - "once_cell", ] [[package]] @@ -6290,7 +6282,6 @@ version = "1.0.0" dependencies = [ "async-tungstenite", "iced", - "once_cell", "tokio", "warp", ] diff --git a/Cargo.toml b/Cargo.toml index eb2251c8db..9059cfd938 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -162,7 +162,6 @@ log = "0.4" lyon = "1.0" lyon_path = "1.0" num-traits = "0.2" -once_cell = "1.0" ouroboros = "0.18" palette = "0.7" png = "0.17" diff --git a/core/Cargo.toml b/core/Cargo.toml index a12289099c..a3bc6745fb 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -23,7 +23,6 @@ bytes.workspace = true glam.workspace = true log.workspace = true num-traits.workspace = true -once_cell.workspace = true palette.workspace = true rustc-hash.workspace = true smol_str.workspace = true diff --git a/core/src/theme.rs b/core/src/theme.rs index 23480cec9b..1f9e4fdfe0 100644 --- a/core/src/theme.rs +++ b/core/src/theme.rs @@ -166,10 +166,10 @@ impl Default for Theme { fn default() -> Self { #[cfg(feature = "auto-detect-theme")] { - use once_cell::sync::Lazy; + use std::sync::LazyLock; - static DEFAULT: Lazy = - Lazy::new(|| match dark_light::detect() { + static DEFAULT: LazyLock = + LazyLock::new(|| match dark_light::detect() { dark_light::Mode::Dark => Theme::Dark, dark_light::Mode::Light | dark_light::Mode::Default => { Theme::Light diff --git a/core/src/theme/palette.rs b/core/src/theme/palette.rs index 00c3801981..5947bf6b57 100644 --- a/core/src/theme/palette.rs +++ b/core/src/theme/palette.rs @@ -1,7 +1,8 @@ //! Define the colors of a theme. +use std::sync::LazyLock; + use crate::{color, Color}; -use once_cell::sync::Lazy; use palette::color_difference::Wcag21RelativeContrast; use palette::rgb::Rgb; use palette::{FromColor, Hsl, Mix}; @@ -341,92 +342,92 @@ pub struct Extended { } /// The built-in light variant of an [`Extended`] palette. -pub static EXTENDED_LIGHT: Lazy = - Lazy::new(|| Extended::generate(Palette::LIGHT)); +pub static EXTENDED_LIGHT: LazyLock = + LazyLock::new(|| Extended::generate(Palette::LIGHT)); /// The built-in dark variant of an [`Extended`] palette. -pub static EXTENDED_DARK: Lazy = - Lazy::new(|| Extended::generate(Palette::DARK)); +pub static EXTENDED_DARK: LazyLock = + LazyLock::new(|| Extended::generate(Palette::DARK)); /// The built-in Dracula variant of an [`Extended`] palette. -pub static EXTENDED_DRACULA: Lazy = - Lazy::new(|| Extended::generate(Palette::DRACULA)); +pub static EXTENDED_DRACULA: LazyLock = + LazyLock::new(|| Extended::generate(Palette::DRACULA)); /// The built-in Nord variant of an [`Extended`] palette. -pub static EXTENDED_NORD: Lazy = - Lazy::new(|| Extended::generate(Palette::NORD)); +pub static EXTENDED_NORD: LazyLock = + LazyLock::new(|| Extended::generate(Palette::NORD)); /// The built-in Solarized Light variant of an [`Extended`] palette. -pub static EXTENDED_SOLARIZED_LIGHT: Lazy = - Lazy::new(|| Extended::generate(Palette::SOLARIZED_LIGHT)); +pub static EXTENDED_SOLARIZED_LIGHT: LazyLock = + LazyLock::new(|| Extended::generate(Palette::SOLARIZED_LIGHT)); /// The built-in Solarized Dark variant of an [`Extended`] palette. -pub static EXTENDED_SOLARIZED_DARK: Lazy = - Lazy::new(|| Extended::generate(Palette::SOLARIZED_DARK)); +pub static EXTENDED_SOLARIZED_DARK: LazyLock = + LazyLock::new(|| Extended::generate(Palette::SOLARIZED_DARK)); /// The built-in Gruvbox Light variant of an [`Extended`] palette. -pub static EXTENDED_GRUVBOX_LIGHT: Lazy = - Lazy::new(|| Extended::generate(Palette::GRUVBOX_LIGHT)); +pub static EXTENDED_GRUVBOX_LIGHT: LazyLock = + LazyLock::new(|| Extended::generate(Palette::GRUVBOX_LIGHT)); /// The built-in Gruvbox Dark variant of an [`Extended`] palette. -pub static EXTENDED_GRUVBOX_DARK: Lazy = - Lazy::new(|| Extended::generate(Palette::GRUVBOX_DARK)); +pub static EXTENDED_GRUVBOX_DARK: LazyLock = + LazyLock::new(|| Extended::generate(Palette::GRUVBOX_DARK)); /// The built-in Catppuccin Latte variant of an [`Extended`] palette. -pub static EXTENDED_CATPPUCCIN_LATTE: Lazy = - Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_LATTE)); +pub static EXTENDED_CATPPUCCIN_LATTE: LazyLock = + LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_LATTE)); /// The built-in Catppuccin Frappé variant of an [`Extended`] palette. -pub static EXTENDED_CATPPUCCIN_FRAPPE: Lazy = - Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_FRAPPE)); +pub static EXTENDED_CATPPUCCIN_FRAPPE: LazyLock = + LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_FRAPPE)); /// The built-in Catppuccin Macchiato variant of an [`Extended`] palette. -pub static EXTENDED_CATPPUCCIN_MACCHIATO: Lazy = - Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_MACCHIATO)); +pub static EXTENDED_CATPPUCCIN_MACCHIATO: LazyLock = + LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_MACCHIATO)); /// The built-in Catppuccin Mocha variant of an [`Extended`] palette. -pub static EXTENDED_CATPPUCCIN_MOCHA: Lazy = - Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_MOCHA)); +pub static EXTENDED_CATPPUCCIN_MOCHA: LazyLock = + LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_MOCHA)); /// The built-in Tokyo Night variant of an [`Extended`] palette. -pub static EXTENDED_TOKYO_NIGHT: Lazy = - Lazy::new(|| Extended::generate(Palette::TOKYO_NIGHT)); +pub static EXTENDED_TOKYO_NIGHT: LazyLock = + LazyLock::new(|| Extended::generate(Palette::TOKYO_NIGHT)); /// The built-in Tokyo Night Storm variant of an [`Extended`] palette. -pub static EXTENDED_TOKYO_NIGHT_STORM: Lazy = - Lazy::new(|| Extended::generate(Palette::TOKYO_NIGHT_STORM)); +pub static EXTENDED_TOKYO_NIGHT_STORM: LazyLock = + LazyLock::new(|| Extended::generate(Palette::TOKYO_NIGHT_STORM)); /// The built-in Tokyo Night variant of an [`Extended`] palette. -pub static EXTENDED_TOKYO_NIGHT_LIGHT: Lazy = - Lazy::new(|| Extended::generate(Palette::TOKYO_NIGHT_LIGHT)); +pub static EXTENDED_TOKYO_NIGHT_LIGHT: LazyLock = + LazyLock::new(|| Extended::generate(Palette::TOKYO_NIGHT_LIGHT)); /// The built-in Kanagawa Wave variant of an [`Extended`] palette. -pub static EXTENDED_KANAGAWA_WAVE: Lazy = - Lazy::new(|| Extended::generate(Palette::KANAGAWA_WAVE)); +pub static EXTENDED_KANAGAWA_WAVE: LazyLock = + LazyLock::new(|| Extended::generate(Palette::KANAGAWA_WAVE)); /// The built-in Kanagawa Dragon variant of an [`Extended`] palette. -pub static EXTENDED_KANAGAWA_DRAGON: Lazy = - Lazy::new(|| Extended::generate(Palette::KANAGAWA_DRAGON)); +pub static EXTENDED_KANAGAWA_DRAGON: LazyLock = + LazyLock::new(|| Extended::generate(Palette::KANAGAWA_DRAGON)); /// The built-in Kanagawa Lotus variant of an [`Extended`] palette. -pub static EXTENDED_KANAGAWA_LOTUS: Lazy = - Lazy::new(|| Extended::generate(Palette::KANAGAWA_LOTUS)); +pub static EXTENDED_KANAGAWA_LOTUS: LazyLock = + LazyLock::new(|| Extended::generate(Palette::KANAGAWA_LOTUS)); /// The built-in Moonfly variant of an [`Extended`] palette. -pub static EXTENDED_MOONFLY: Lazy = - Lazy::new(|| Extended::generate(Palette::MOONFLY)); +pub static EXTENDED_MOONFLY: LazyLock = + LazyLock::new(|| Extended::generate(Palette::MOONFLY)); /// The built-in Nightfly variant of an [`Extended`] palette. -pub static EXTENDED_NIGHTFLY: Lazy = - Lazy::new(|| Extended::generate(Palette::NIGHTFLY)); +pub static EXTENDED_NIGHTFLY: LazyLock = + LazyLock::new(|| Extended::generate(Palette::NIGHTFLY)); /// The built-in Oxocarbon variant of an [`Extended`] palette. -pub static EXTENDED_OXOCARBON: Lazy = - Lazy::new(|| Extended::generate(Palette::OXOCARBON)); +pub static EXTENDED_OXOCARBON: LazyLock = + LazyLock::new(|| Extended::generate(Palette::OXOCARBON)); /// The built-in Ferra variant of an [`Extended`] palette. -pub static EXTENDED_FERRA: Lazy = - Lazy::new(|| Extended::generate(Palette::FERRA)); +pub static EXTENDED_FERRA: LazyLock = + LazyLock::new(|| Extended::generate(Palette::FERRA)); impl Extended { /// Generates an [`Extended`] palette from a simple [`Palette`]. diff --git a/examples/loading_spinners/Cargo.toml b/examples/loading_spinners/Cargo.toml index a32da3864c..abd28aec87 100644 --- a/examples/loading_spinners/Cargo.toml +++ b/examples/loading_spinners/Cargo.toml @@ -10,4 +10,3 @@ iced.workspace = true iced.features = ["advanced", "canvas"] lyon_algorithms = "1.0" -once_cell.workspace = true \ No newline at end of file diff --git a/examples/loading_spinners/src/easing.rs b/examples/loading_spinners/src/easing.rs index 45089ef66e..be644d31a0 100644 --- a/examples/loading_spinners/src/easing.rs +++ b/examples/loading_spinners/src/easing.rs @@ -1,41 +1,42 @@ +use std::sync::LazyLock; + use iced::Point; use lyon_algorithms::measure::PathMeasurements; use lyon_algorithms::path::{builder::NoAttributes, path::BuilderImpl, Path}; -use once_cell::sync::Lazy; -pub static EMPHASIZED: Lazy = Lazy::new(|| { +pub static EMPHASIZED: LazyLock = LazyLock::new(|| { Easing::builder() .cubic_bezier_to([0.05, 0.0], [0.133333, 0.06], [0.166666, 0.4]) .cubic_bezier_to([0.208333, 0.82], [0.25, 1.0], [1.0, 1.0]) .build() }); -pub static EMPHASIZED_DECELERATE: Lazy = Lazy::new(|| { +pub static EMPHASIZED_DECELERATE: LazyLock = LazyLock::new(|| { Easing::builder() .cubic_bezier_to([0.05, 0.7], [0.1, 1.0], [1.0, 1.0]) .build() }); -pub static EMPHASIZED_ACCELERATE: Lazy = Lazy::new(|| { +pub static EMPHASIZED_ACCELERATE: LazyLock = LazyLock::new(|| { Easing::builder() .cubic_bezier_to([0.3, 0.0], [0.8, 0.15], [1.0, 1.0]) .build() }); -pub static STANDARD: Lazy = Lazy::new(|| { +pub static STANDARD: LazyLock = LazyLock::new(|| { Easing::builder() .cubic_bezier_to([0.2, 0.0], [0.0, 1.0], [1.0, 1.0]) .build() }); -pub static STANDARD_DECELERATE: Lazy = Lazy::new(|| { +pub static STANDARD_DECELERATE: LazyLock = LazyLock::new(|| { Easing::builder() .cubic_bezier_to([0.0, 0.0], [0.0, 1.0], [1.0, 1.0]) .build() }); -pub static STANDARD_ACCELERATE: Lazy = Lazy::new(|| { +pub static STANDARD_ACCELERATE: LazyLock = LazyLock::new(|| { Easing::builder() .cubic_bezier_to([0.3, 0.0], [1.0, 1.0], [1.0, 1.0]) .build() diff --git a/examples/scrollable/Cargo.toml b/examples/scrollable/Cargo.toml index f8c735c014..ba29152065 100644 --- a/examples/scrollable/Cargo.toml +++ b/examples/scrollable/Cargo.toml @@ -8,5 +8,3 @@ publish = false [dependencies] iced.workspace = true iced.features = ["debug"] - -once_cell.workspace = true diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs index de4f2f9ada..bd12e43b1e 100644 --- a/examples/scrollable/src/main.rs +++ b/examples/scrollable/src/main.rs @@ -1,12 +1,13 @@ +use std::sync::LazyLock; + use iced::widget::{ button, column, container, horizontal_space, progress_bar, radio, row, scrollable, slider, text, vertical_space, }; use iced::{Border, Center, Color, Element, Fill, Task, Theme}; -use once_cell::sync::Lazy; - -static SCROLLABLE_ID: Lazy = Lazy::new(scrollable::Id::unique); +static SCROLLABLE_ID: LazyLock = + LazyLock::new(scrollable::Id::unique); pub fn main() -> iced::Result { iced::application( diff --git a/examples/visible_bounds/Cargo.toml b/examples/visible_bounds/Cargo.toml index 37594b847d..1193334d41 100644 --- a/examples/visible_bounds/Cargo.toml +++ b/examples/visible_bounds/Cargo.toml @@ -8,5 +8,3 @@ publish = false [dependencies] iced.workspace = true iced.features = ["debug"] - -once_cell.workspace = true diff --git a/examples/visible_bounds/src/main.rs b/examples/visible_bounds/src/main.rs index 77fec65ea5..f8f9f4206f 100644 --- a/examples/visible_bounds/src/main.rs +++ b/examples/visible_bounds/src/main.rs @@ -157,9 +157,9 @@ impl Example { } } -use once_cell::sync::Lazy; +use std::sync::LazyLock; -static OUTER_CONTAINER: Lazy = - Lazy::new(|| container::Id::new("outer")); -static INNER_CONTAINER: Lazy = - Lazy::new(|| container::Id::new("inner")); +static OUTER_CONTAINER: LazyLock = + LazyLock::new(|| container::Id::new("outer")); +static INNER_CONTAINER: LazyLock = + LazyLock::new(|| container::Id::new("inner")); diff --git a/examples/websocket/Cargo.toml b/examples/websocket/Cargo.toml index c7075fb301..787dbbe164 100644 --- a/examples/websocket/Cargo.toml +++ b/examples/websocket/Cargo.toml @@ -9,7 +9,6 @@ publish = false iced.workspace = true iced.features = ["debug", "tokio"] -once_cell.workspace = true warp = "0.3" [dependencies.async-tungstenite] diff --git a/examples/websocket/src/main.rs b/examples/websocket/src/main.rs index 8b1efb4125..399ce2ff16 100644 --- a/examples/websocket/src/main.rs +++ b/examples/websocket/src/main.rs @@ -1,10 +1,11 @@ mod echo; +use std::sync::LazyLock; + use iced::widget::{ self, button, center, column, row, scrollable, text, text_input, }; use iced::{color, Center, Element, Fill, Subscription, Task}; -use once_cell::sync::Lazy; pub fn main() -> iced::Result { iced::application("WebSocket - Iced", WebSocket::update, WebSocket::view) @@ -138,4 +139,5 @@ enum State { Connected(echo::Connection), } -static MESSAGE_LOG: Lazy = Lazy::new(scrollable::Id::unique); +static MESSAGE_LOG: LazyLock = + LazyLock::new(scrollable::Id::unique); diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml index 7e2d767b27..43191a5995 100644 --- a/graphics/Cargo.toml +++ b/graphics/Cargo.toml @@ -33,7 +33,6 @@ bytemuck.workspace = true cosmic-text.workspace = true half.workspace = true log.workspace = true -once_cell.workspace = true raw-window-handle.workspace = true rustc-hash.workspace = true thiserror.workspace = true diff --git a/graphics/src/text.rs b/graphics/src/text.rs index ca3fc6fc83..7694ff1fe6 100644 --- a/graphics/src/text.rs +++ b/graphics/src/text.rs @@ -14,10 +14,9 @@ use crate::core::font::{self, Font}; use crate::core::text::{Shaping, Wrapping}; use crate::core::{Color, Pixels, Point, Rectangle, Size, Transformation}; -use once_cell::sync::OnceCell; use std::borrow::Cow; use std::collections::HashSet; -use std::sync::{Arc, RwLock, Weak}; +use std::sync::{Arc, OnceLock, RwLock, Weak}; /// A text primitive. #[derive(Debug, Clone, PartialEq)] @@ -157,7 +156,7 @@ pub const FIRA_SANS_REGULAR: &[u8] = /// Returns the global [`FontSystem`]. pub fn font_system() -> &'static RwLock { - static FONT_SYSTEM: OnceCell> = OnceCell::new(); + static FONT_SYSTEM: OnceLock> = OnceLock::new(); FONT_SYSTEM.get_or_init(|| { RwLock::new(FontSystem { diff --git a/highlighter/Cargo.toml b/highlighter/Cargo.toml index 7962b89dda..4c20a67839 100644 --- a/highlighter/Cargo.toml +++ b/highlighter/Cargo.toml @@ -16,5 +16,4 @@ workspace = true [dependencies] iced_core.workspace = true -once_cell.workspace = true syntect.workspace = true diff --git a/highlighter/src/lib.rs b/highlighter/src/lib.rs index 83a15cb1f0..d2abc6b12a 100644 --- a/highlighter/src/lib.rs +++ b/highlighter/src/lib.rs @@ -5,16 +5,16 @@ use crate::core::font::{self, Font}; use crate::core::text::highlighter::{self, Format}; use crate::core::Color; -use once_cell::sync::Lazy; use std::ops::Range; +use std::sync::LazyLock; use syntect::highlighting; use syntect::parsing; -static SYNTAXES: Lazy = - Lazy::new(parsing::SyntaxSet::load_defaults_nonewlines); +static SYNTAXES: LazyLock = + LazyLock::new(parsing::SyntaxSet::load_defaults_nonewlines); -static THEMES: Lazy = - Lazy::new(highlighting::ThemeSet::load_defaults); +static THEMES: LazyLock = + LazyLock::new(highlighting::ThemeSet::load_defaults); const LINES_PER_SNAPSHOT: usize = 50; diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index a8ebf3aa85..4b6b0483a6 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -35,7 +35,6 @@ glam.workspace = true glyphon.workspace = true guillotiere.workspace = true log.workspace = true -once_cell.workspace = true rustc-hash.workspace = true thiserror.workspace = true wgpu.workspace = true diff --git a/widget/Cargo.toml b/widget/Cargo.toml index 98a8114582..e19cad0843 100644 --- a/widget/Cargo.toml +++ b/widget/Cargo.toml @@ -33,7 +33,6 @@ iced_renderer.workspace = true iced_runtime.workspace = true num-traits.workspace = true -once_cell.workspace = true rustc-hash.workspace = true thiserror.workspace = true unicode-segmentation.workspace = true diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index cdfd2dafff..563d84e28a 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -1706,11 +1706,12 @@ where + 'a, Theme: text::Catalog + crate::svg::Catalog + 'a, { + use std::sync::LazyLock; + use crate::core::{Alignment, Font}; use crate::svg; - use once_cell::sync::Lazy; - static LOGO: Lazy = Lazy::new(|| { + static LOGO: LazyLock = LazyLock::new(|| { svg::Handle::from_memory(include_bytes!("../assets/iced-logo.svg")) }); From 2b8b3fd413b03d6b79f1de90bd42eb43c5cd6aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 6 Jan 2025 23:00:21 +0100 Subject: [PATCH 2/2] Fix consistency of import ordering --- core/src/theme/palette.rs | 4 ++-- examples/loading_spinners/src/easing.rs | 4 ++-- examples/scrollable/src/main.rs | 4 ++-- examples/websocket/src/main.rs | 3 +-- widget/src/helpers.rs | 3 +-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/src/theme/palette.rs b/core/src/theme/palette.rs index 5947bf6b57..696c01d047 100644 --- a/core/src/theme/palette.rs +++ b/core/src/theme/palette.rs @@ -1,12 +1,12 @@ //! Define the colors of a theme. -use std::sync::LazyLock; - use crate::{color, Color}; use palette::color_difference::Wcag21RelativeContrast; use palette::rgb::Rgb; use palette::{FromColor, Hsl, Mix}; +use std::sync::LazyLock; + /// A color palette. #[derive(Debug, Clone, Copy, PartialEq)] pub struct Palette { diff --git a/examples/loading_spinners/src/easing.rs b/examples/loading_spinners/src/easing.rs index be644d31a0..8caf282d49 100644 --- a/examples/loading_spinners/src/easing.rs +++ b/examples/loading_spinners/src/easing.rs @@ -1,10 +1,10 @@ -use std::sync::LazyLock; - use iced::Point; use lyon_algorithms::measure::PathMeasurements; use lyon_algorithms::path::{builder::NoAttributes, path::BuilderImpl, Path}; +use std::sync::LazyLock; + pub static EMPHASIZED: LazyLock = LazyLock::new(|| { Easing::builder() .cubic_bezier_to([0.05, 0.0], [0.133333, 0.06], [0.166666, 0.4]) diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs index bd12e43b1e..6359fb5a19 100644 --- a/examples/scrollable/src/main.rs +++ b/examples/scrollable/src/main.rs @@ -1,11 +1,11 @@ -use std::sync::LazyLock; - use iced::widget::{ button, column, container, horizontal_space, progress_bar, radio, row, scrollable, slider, text, vertical_space, }; use iced::{Border, Center, Color, Element, Fill, Task, Theme}; +use std::sync::LazyLock; + static SCROLLABLE_ID: LazyLock = LazyLock::new(scrollable::Id::unique); diff --git a/examples/websocket/src/main.rs b/examples/websocket/src/main.rs index 399ce2ff16..ae658471df 100644 --- a/examples/websocket/src/main.rs +++ b/examples/websocket/src/main.rs @@ -1,11 +1,10 @@ mod echo; -use std::sync::LazyLock; - use iced::widget::{ self, button, center, column, row, scrollable, text, text_input, }; use iced::{color, Center, Element, Fill, Subscription, Task}; +use std::sync::LazyLock; pub fn main() -> iced::Result { iced::application("WebSocket - Iced", WebSocket::update, WebSocket::view) diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index 563d84e28a..5a0f81071d 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -1706,10 +1706,9 @@ where + 'a, Theme: text::Catalog + crate::svg::Catalog + 'a, { - use std::sync::LazyLock; - use crate::core::{Alignment, Font}; use crate::svg; + use std::sync::LazyLock; static LOGO: LazyLock = LazyLock::new(|| { svg::Handle::from_memory(include_bytes!("../assets/iced-logo.svg"))