aboutsummaryrefslogtreecommitdiff
path: root/azalea-chat
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-11-27 10:26:40 +0000
committermat <git@matdoes.dev>2024-11-27 10:26:40 +0000
commit0817382098128adcecb77756a3c7cd1bd0066057 (patch)
tree623d9b297f9b5fdb2af74ab3c5a4fa5c1b72ff5b /azalea-chat
parentdfdc3144b61b6750ad62fb493b7c00c6c820c90b (diff)
downloadazalea-drasl-0817382098128adcecb77756a3c7cd1bd0066057.tar.xz
replace once_cell with std:;sync::LazyLock
Diffstat (limited to 'azalea-chat')
-rw-r--r--azalea-chat/Cargo.toml5
-rwxr-xr-xazalea-chat/src/component.rs5
-rwxr-xr-xazalea-chat/src/style.rs9
3 files changed, 9 insertions, 10 deletions
diff --git a/azalea-chat/Cargo.toml b/azalea-chat/Cargo.toml
index 6cd9c16e..370a8862 100644
--- a/azalea-chat/Cargo.toml
+++ b/azalea-chat/Cargo.toml
@@ -15,10 +15,11 @@ azalea-buf = ["dep:azalea-buf", "simdnbt"]
numbers = ["dep:azalea-registry", "dep:simdnbt"]
[dependencies]
-azalea-buf = { path = "../azalea-buf", features = ["serde_json"], version = "0.10.0", optional = true }
+azalea-buf = { path = "../azalea-buf", features = [
+ "serde_json",
+], version = "0.10.0", optional = true }
azalea-language = { path = "../azalea-language", version = "0.10.0" }
azalea-registry = { path = "../azalea-registry", version = "0.10.0", optional = true }
-once_cell = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
simdnbt = { workspace = true, optional = true }
diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs
index 84b5ed17..43614c77 100755
--- a/azalea-chat/src/component.rs
+++ b/azalea-chat/src/component.rs
@@ -1,8 +1,7 @@
-use std::fmt::Display;
+use std::{fmt::Display, sync::LazyLock};
#[cfg(feature = "azalea-buf")]
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
-use once_cell::sync::Lazy;
use serde::{de, Deserialize, Deserializer, Serialize};
#[cfg(feature = "simdnbt")]
use simdnbt::{Deserialize as _, FromNbtTag as _, Serialize as _};
@@ -23,7 +22,7 @@ pub enum FormattedText {
Translatable(TranslatableComponent),
}
-pub static DEFAULT_STYLE: Lazy<Style> = Lazy::new(|| Style {
+pub static DEFAULT_STYLE: LazyLock<Style> = LazyLock::new(|| Style {
color: Some(ChatFormatting::White.try_into().unwrap()),
..Style::default()
});
diff --git a/azalea-chat/src/style.rs b/azalea-chat/src/style.rs
index a27f3d2a..e147bc97 100755
--- a/azalea-chat/src/style.rs
+++ b/azalea-chat/src/style.rs
@@ -1,8 +1,7 @@
-use std::{collections::HashMap, fmt};
+use std::{collections::HashMap, fmt, sync::LazyLock};
#[cfg(feature = "azalea-buf")]
use azalea_buf::McBuf;
-use once_cell::sync::Lazy;
use serde::{ser::SerializeStruct, Serialize, Serializer};
use serde_json::Value;
#[cfg(feature = "simdnbt")]
@@ -57,8 +56,8 @@ impl TextColor {
}
}
-static LEGACY_FORMAT_TO_COLOR: Lazy<HashMap<&'static ChatFormatting, TextColor>> =
- Lazy::new(|| {
+static LEGACY_FORMAT_TO_COLOR: LazyLock<HashMap<&'static ChatFormatting, TextColor>> =
+ LazyLock::new(|| {
let mut legacy_format_to_color = HashMap::new();
for formatter in &ChatFormatting::FORMATTERS {
if !formatter.is_format() && *formatter != ChatFormatting::Reset {
@@ -73,7 +72,7 @@ static LEGACY_FORMAT_TO_COLOR: Lazy<HashMap<&'static ChatFormatting, TextColor>>
}
legacy_format_to_color
});
-static NAMED_COLORS: Lazy<HashMap<String, TextColor>> = Lazy::new(|| {
+static NAMED_COLORS: LazyLock<HashMap<String, TextColor>> = LazyLock::new(|| {
let mut named_colors = HashMap::new();
for color in LEGACY_FORMAT_TO_COLOR.values() {
named_colors.insert(color.name.clone().unwrap(), color.clone());