summaryrefslogtreecommitdiffstats
path: root/examples/websocket
diff options
context:
space:
mode:
authorLibravatar Ian Douglas Scott <idscott@system76.com>2022-10-28 14:43:18 -0700
committerLibravatar Ian Douglas Scott <idscott@system76.com>2022-10-28 15:58:21 -0700
commitbe9cd3a09f4fb027786c634158ddeaca75a169f0 (patch)
tree3685a32b728bf6cfe426f46c437574f62a3d53db /examples/websocket
parent82217947aa80287282ed6deb02d238a31303e0d6 (diff)
downloadiced-be9cd3a09f4fb027786c634158ddeaca75a169f0.tar.gz
iced-be9cd3a09f4fb027786c634158ddeaca75a169f0.tar.bz2
iced-be9cd3a09f4fb027786c634158ddeaca75a169f0.zip
Use `once_cell` instead of `lazy_static`
This seems to be generally considered the preferred, idiomatic solution now. This is in the standard library behind a feature flag (apparently now called `std::sync::LazyLock`).
Diffstat (limited to 'examples/websocket')
-rw-r--r--examples/websocket/Cargo.toml2
-rw-r--r--examples/websocket/src/main.rs5
2 files changed, 3 insertions, 4 deletions
diff --git a/examples/websocket/Cargo.toml b/examples/websocket/Cargo.toml
index 3981f699..fcb4dd3f 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.0"
[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);