aboutsummaryrefslogtreecommitdiff
path: root/azalea-chat/src/style.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2022-11-19 15:21:54 -0600
committerGitHub <noreply@github.com>2022-11-19 15:21:54 -0600
commit619984fa33aec8b9629770928c51ee81a3d3a63f (patch)
treefa6de3852d08dea6f77ba2549d98b9fcb457309a /azalea-chat/src/style.rs
parentbefa22c1f3ff0c1f0cb745b3f4e736910c053a8b (diff)
downloadazalea-drasl-619984fa33aec8b9629770928c51ee81a3d3a63f.tar.xz
Replace lazy_static with once_cell::sync::Lazy (#43)
* Remove lazy_static in azalea-chat * replace lazy_static with once_cell everywhere * fix * fix import * ignore a clippy warning in shape codegen
Diffstat (limited to 'azalea-chat/src/style.rs')
-rwxr-xr-xazalea-chat/src/style.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/azalea-chat/src/style.rs b/azalea-chat/src/style.rs
index 6422d5e4..1243d56f 100755
--- a/azalea-chat/src/style.rs
+++ b/azalea-chat/src/style.rs
@@ -1,6 +1,7 @@
use std::{collections::HashMap, fmt};
use azalea_buf::McBuf;
+use once_cell::sync::Lazy;
use serde_json::Value;
#[derive(Clone, PartialEq, Eq, Debug)]
@@ -28,8 +29,8 @@ impl TextColor {
}
}
-lazy_static! {
- static ref LEGACY_FORMAT_TO_COLOR: HashMap<&'static ChatFormatting, TextColor> = {
+static LEGACY_FORMAT_TO_COLOR: Lazy<HashMap<&'static ChatFormatting, TextColor>> =
+ Lazy::new(|| {
let mut legacy_format_to_color = HashMap::new();
for formatter in &ChatFormatting::FORMATTERS {
if !formatter.is_format() && *formatter != ChatFormatting::Reset {
@@ -43,15 +44,14 @@ lazy_static! {
}
}
legacy_format_to_color
- };
- static ref NAMED_COLORS: HashMap<String, TextColor> = {
- let mut named_colors = HashMap::new();
- for color in LEGACY_FORMAT_TO_COLOR.values() {
- named_colors.insert(color.name.clone().unwrap(), color.clone());
- }
- named_colors
- };
-}
+ });
+static NAMED_COLORS: Lazy<HashMap<String, TextColor>> = Lazy::new(|| {
+ let mut named_colors = HashMap::new();
+ for color in LEGACY_FORMAT_TO_COLOR.values() {
+ named_colors.insert(color.name.clone().unwrap(), color.clone());
+ }
+ named_colors
+});
pub struct Ansi {}
impl Ansi {