summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-11-01 20:18:42 +0100
committerLibravatar GitHub <noreply@github.com>2022-11-01 20:18:42 +0100
commit1c00adad615f7c2909d175c696765dbe081bde33 (patch)
tree76ac2acb891cdf6cde7b00e33da600837cfcc97f
parent37c5b15f62ef44e52e49032a2972a76aa653436a (diff)
parent743a7192b70bc5184aa47e7851098b75b8a1f288 (diff)
downloadiced-1c00adad615f7c2909d175c696765dbe081bde33.tar.gz
iced-1c00adad615f7c2909d175c696765dbe081bde33.tar.bz2
iced-1c00adad615f7c2909d175c696765dbe081bde33.zip
Merge pull request #1497 from ids1024/once_cell
Use `once_cell` instead of `lazy_static`
Diffstat (limited to '')
-rw-r--r--examples/todos/Cargo.toml2
-rw-r--r--examples/todos/src/main.rs6
-rw-r--r--examples/websocket/Cargo.toml2
-rw-r--r--examples/websocket/src/main.rs5
-rw-r--r--style/Cargo.toml4
-rw-r--r--style/src/theme/palette.rs11
6 files changed, 13 insertions, 17 deletions
diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml
index 2326ffc6..7ad4d558 100644
--- a/examples/todos/Cargo.toml
+++ b/examples/todos/Cargo.toml
@@ -9,7 +9,7 @@ publish = false
iced = { path = "../..", features = ["async-std", "debug"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
-lazy_static = "1.4"
+once_cell = "1.15"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
async-std = "1.0"
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index bddc0e71..be48ae8c 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -11,12 +11,10 @@ use iced::window;
use iced::{Application, Element};
use iced::{Color, Command, Font, Length, Settings, Subscription};
-use lazy_static::lazy_static;
+use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
-lazy_static! {
- static ref INPUT_ID: text_input::Id = text_input::Id::unique();
-}
+static INPUT_ID: Lazy<text_input::Id> = Lazy::new(text_input::Id::unique);
pub fn main() -> iced::Result {
Todos::run(Settings {
diff --git a/examples/websocket/Cargo.toml b/examples/websocket/Cargo.toml
index 3981f699..c25f067b 100644
--- a/examples/websocket/Cargo.toml
+++ b/examples/websocket/Cargo.toml
@@ -9,7 +9,7 @@ publish = false
iced = { path = "../..", features = ["tokio", "debug"] }
iced_native = { path = "../../native" }
iced_futures = { path = "../../futures" }
-lazy_static = "1.4"
+once_cell = "1.15"
[dependencies.async-tungstenite]
version = "0.16"
diff --git a/examples/websocket/src/main.rs b/examples/websocket/src/main.rs
index 3902e04c..ff2929da 100644
--- a/examples/websocket/src/main.rs
+++ b/examples/websocket/src/main.rs
@@ -8,6 +8,7 @@ use iced::widget::{
use iced::{
Application, Color, Command, Element, Length, Settings, Subscription, Theme,
};
+use once_cell::sync::Lazy;
pub fn main() -> iced::Result {
WebSocket::run(Settings::default())
@@ -165,6 +166,4 @@ impl Default for State {
}
}
-lazy_static::lazy_static! {
- static ref MESSAGE_LOG: scrollable::Id = scrollable::Id::unique();
-}
+static MESSAGE_LOG: Lazy<scrollable::Id> = Lazy::new(scrollable::Id::unique);
diff --git a/style/Cargo.toml b/style/Cargo.toml
index cf9d328b..4a482a4f 100644
--- a/style/Cargo.toml
+++ b/style/Cargo.toml
@@ -18,5 +18,5 @@ features = ["palette"]
[dependencies.palette]
version = "0.6"
-[dependencies.lazy_static]
-version = "1.4"
+[dependencies.once_cell]
+version = "1.15"
diff --git a/style/src/theme/palette.rs b/style/src/theme/palette.rs
index 81aa9cc7..4fb5e4c8 100644
--- a/style/src/theme/palette.rs
+++ b/style/src/theme/palette.rs
@@ -1,6 +1,6 @@
use iced_core::Color;
-use lazy_static::lazy_static;
+use once_cell::sync::Lazy;
use palette::{FromColor, Hsl, Mix, RelativeContrast, Srgb};
#[derive(Debug, Clone, Copy, PartialEq)]
@@ -66,11 +66,10 @@ pub struct Extended {
pub danger: Danger,
}
-lazy_static! {
- pub static ref EXTENDED_LIGHT: Extended =
- Extended::generate(Palette::LIGHT);
- pub static ref EXTENDED_DARK: Extended = Extended::generate(Palette::DARK);
-}
+pub static EXTENDED_LIGHT: Lazy<Extended> =
+ Lazy::new(|| Extended::generate(Palette::LIGHT));
+pub static EXTENDED_DARK: Lazy<Extended> =
+ Lazy::new(|| Extended::generate(Palette::DARK));
impl Extended {
pub fn generate(palette: Palette) -> Self {