Skip to content

Commit

Permalink
Merge pull request #2626 from tvolk131/remove_once_cell
Browse files Browse the repository at this point in the history
chore: remove once_cell dependency
  • Loading branch information
hecrj authored Jan 6, 2025
2 parents 6343655 + 2b8b3fd commit 717b296
Show file tree
Hide file tree
Showing 20 changed files with 77 additions and 95 deletions.
9 changes: 0 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions core/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Theme> =
Lazy::new(|| match dark_light::detect() {
static DEFAULT: LazyLock<Theme> =
LazyLock::new(|| match dark_light::detect() {
dark_light::Mode::Dark => Theme::Dark,
dark_light::Mode::Light | dark_light::Mode::Default => {
Theme::Light
Expand Down
91 changes: 46 additions & 45 deletions core/src/theme/palette.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//! Define the colors of a theme.
use crate::{color, Color};

use once_cell::sync::Lazy;
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 {
Expand Down Expand Up @@ -341,92 +342,92 @@ pub struct Extended {
}

/// The built-in light variant of an [`Extended`] palette.
pub static EXTENDED_LIGHT: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::LIGHT));
pub static EXTENDED_LIGHT: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::LIGHT));

/// The built-in dark variant of an [`Extended`] palette.
pub static EXTENDED_DARK: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::DARK));
pub static EXTENDED_DARK: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::DARK));

/// The built-in Dracula variant of an [`Extended`] palette.
pub static EXTENDED_DRACULA: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::DRACULA));
pub static EXTENDED_DRACULA: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::DRACULA));

/// The built-in Nord variant of an [`Extended`] palette.
pub static EXTENDED_NORD: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::NORD));
pub static EXTENDED_NORD: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::NORD));

/// The built-in Solarized Light variant of an [`Extended`] palette.
pub static EXTENDED_SOLARIZED_LIGHT: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::SOLARIZED_LIGHT));
pub static EXTENDED_SOLARIZED_LIGHT: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::SOLARIZED_LIGHT));

/// The built-in Solarized Dark variant of an [`Extended`] palette.
pub static EXTENDED_SOLARIZED_DARK: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::SOLARIZED_DARK));
pub static EXTENDED_SOLARIZED_DARK: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::SOLARIZED_DARK));

/// The built-in Gruvbox Light variant of an [`Extended`] palette.
pub static EXTENDED_GRUVBOX_LIGHT: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::GRUVBOX_LIGHT));
pub static EXTENDED_GRUVBOX_LIGHT: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::GRUVBOX_LIGHT));

/// The built-in Gruvbox Dark variant of an [`Extended`] palette.
pub static EXTENDED_GRUVBOX_DARK: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::GRUVBOX_DARK));
pub static EXTENDED_GRUVBOX_DARK: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::GRUVBOX_DARK));

/// The built-in Catppuccin Latte variant of an [`Extended`] palette.
pub static EXTENDED_CATPPUCCIN_LATTE: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_LATTE));
pub static EXTENDED_CATPPUCCIN_LATTE: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_LATTE));

/// The built-in Catppuccin Frappé variant of an [`Extended`] palette.
pub static EXTENDED_CATPPUCCIN_FRAPPE: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_FRAPPE));
pub static EXTENDED_CATPPUCCIN_FRAPPE: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_FRAPPE));

/// The built-in Catppuccin Macchiato variant of an [`Extended`] palette.
pub static EXTENDED_CATPPUCCIN_MACCHIATO: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_MACCHIATO));
pub static EXTENDED_CATPPUCCIN_MACCHIATO: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_MACCHIATO));

/// The built-in Catppuccin Mocha variant of an [`Extended`] palette.
pub static EXTENDED_CATPPUCCIN_MOCHA: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_MOCHA));
pub static EXTENDED_CATPPUCCIN_MOCHA: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_MOCHA));

/// The built-in Tokyo Night variant of an [`Extended`] palette.
pub static EXTENDED_TOKYO_NIGHT: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::TOKYO_NIGHT));
pub static EXTENDED_TOKYO_NIGHT: LazyLock<Extended> =
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<Extended> =
Lazy::new(|| Extended::generate(Palette::TOKYO_NIGHT_STORM));
pub static EXTENDED_TOKYO_NIGHT_STORM: LazyLock<Extended> =
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<Extended> =
Lazy::new(|| Extended::generate(Palette::TOKYO_NIGHT_LIGHT));
pub static EXTENDED_TOKYO_NIGHT_LIGHT: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::TOKYO_NIGHT_LIGHT));

/// The built-in Kanagawa Wave variant of an [`Extended`] palette.
pub static EXTENDED_KANAGAWA_WAVE: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::KANAGAWA_WAVE));
pub static EXTENDED_KANAGAWA_WAVE: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::KANAGAWA_WAVE));

/// The built-in Kanagawa Dragon variant of an [`Extended`] palette.
pub static EXTENDED_KANAGAWA_DRAGON: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::KANAGAWA_DRAGON));
pub static EXTENDED_KANAGAWA_DRAGON: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::KANAGAWA_DRAGON));

/// The built-in Kanagawa Lotus variant of an [`Extended`] palette.
pub static EXTENDED_KANAGAWA_LOTUS: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::KANAGAWA_LOTUS));
pub static EXTENDED_KANAGAWA_LOTUS: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::KANAGAWA_LOTUS));

/// The built-in Moonfly variant of an [`Extended`] palette.
pub static EXTENDED_MOONFLY: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::MOONFLY));
pub static EXTENDED_MOONFLY: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::MOONFLY));

/// The built-in Nightfly variant of an [`Extended`] palette.
pub static EXTENDED_NIGHTFLY: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::NIGHTFLY));
pub static EXTENDED_NIGHTFLY: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::NIGHTFLY));

/// The built-in Oxocarbon variant of an [`Extended`] palette.
pub static EXTENDED_OXOCARBON: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::OXOCARBON));
pub static EXTENDED_OXOCARBON: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::OXOCARBON));

/// The built-in Ferra variant of an [`Extended`] palette.
pub static EXTENDED_FERRA: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::FERRA));
pub static EXTENDED_FERRA: LazyLock<Extended> =
LazyLock::new(|| Extended::generate(Palette::FERRA));

impl Extended {
/// Generates an [`Extended`] palette from a simple [`Palette`].
Expand Down
1 change: 0 additions & 1 deletion examples/loading_spinners/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ iced.workspace = true
iced.features = ["advanced", "canvas"]

lyon_algorithms = "1.0"
once_cell.workspace = true
15 changes: 8 additions & 7 deletions examples/loading_spinners/src/easing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,41 @@ 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<Easing> = Lazy::new(|| {
use std::sync::LazyLock;

pub static EMPHASIZED: LazyLock<Easing> = 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<Easing> = Lazy::new(|| {
pub static EMPHASIZED_DECELERATE: LazyLock<Easing> = 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<Easing> = Lazy::new(|| {
pub static EMPHASIZED_ACCELERATE: LazyLock<Easing> = LazyLock::new(|| {
Easing::builder()
.cubic_bezier_to([0.3, 0.0], [0.8, 0.15], [1.0, 1.0])
.build()
});

pub static STANDARD: Lazy<Easing> = Lazy::new(|| {
pub static STANDARD: LazyLock<Easing> = 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<Easing> = Lazy::new(|| {
pub static STANDARD_DECELERATE: LazyLock<Easing> = 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<Easing> = Lazy::new(|| {
pub static STANDARD_ACCELERATE: LazyLock<Easing> = LazyLock::new(|| {
Easing::builder()
.cubic_bezier_to([0.3, 0.0], [1.0, 1.0], [1.0, 1.0])
.build()
Expand Down
2 changes: 0 additions & 2 deletions examples/scrollable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ publish = false
[dependencies]
iced.workspace = true
iced.features = ["debug"]

once_cell.workspace = true
5 changes: 3 additions & 2 deletions examples/scrollable/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use iced::widget::{
};
use iced::{Border, Center, Color, Element, Fill, Task, Theme};

use once_cell::sync::Lazy;
use std::sync::LazyLock;

static SCROLLABLE_ID: Lazy<scrollable::Id> = Lazy::new(scrollable::Id::unique);
static SCROLLABLE_ID: LazyLock<scrollable::Id> =
LazyLock::new(scrollable::Id::unique);

pub fn main() -> iced::Result {
iced::application(
Expand Down
2 changes: 0 additions & 2 deletions examples/visible_bounds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ publish = false
[dependencies]
iced.workspace = true
iced.features = ["debug"]

once_cell.workspace = true
10 changes: 5 additions & 5 deletions examples/visible_bounds/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ impl Example {
}
}

use once_cell::sync::Lazy;
use std::sync::LazyLock;

static OUTER_CONTAINER: Lazy<container::Id> =
Lazy::new(|| container::Id::new("outer"));
static INNER_CONTAINER: Lazy<container::Id> =
Lazy::new(|| container::Id::new("inner"));
static OUTER_CONTAINER: LazyLock<container::Id> =
LazyLock::new(|| container::Id::new("outer"));
static INNER_CONTAINER: LazyLock<container::Id> =
LazyLock::new(|| container::Id::new("inner"));
1 change: 0 additions & 1 deletion examples/websocket/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ publish = false
iced.workspace = true
iced.features = ["debug", "tokio"]

once_cell.workspace = true
warp = "0.3"

[dependencies.async-tungstenite]
Expand Down
5 changes: 3 additions & 2 deletions examples/websocket/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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;
use std::sync::LazyLock;

pub fn main() -> iced::Result {
iced::application("WebSocket - Iced", WebSocket::update, WebSocket::view)
Expand Down Expand Up @@ -138,4 +138,5 @@ enum State {
Connected(echo::Connection),
}

static MESSAGE_LOG: Lazy<scrollable::Id> = Lazy::new(scrollable::Id::unique);
static MESSAGE_LOG: LazyLock<scrollable::Id> =
LazyLock::new(scrollable::Id::unique);
1 change: 0 additions & 1 deletion graphics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 717b296

Please sign in to comment.