From 619984fa33aec8b9629770928c51ee81a3d3a63f Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sat, 19 Nov 2022 15:21:54 -0600 Subject: [PATCH] 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 --- Cargo.lock | 8 +- azalea-chat/Cargo.toml | 2 +- azalea-chat/src/component.rs | 25 +- azalea-chat/src/lib.rs | 3 - azalea-chat/src/style.rs | 22 +- azalea-client/Cargo.toml | 2 +- azalea-client/src/chat.rs | 15 +- azalea-language/Cargo.toml | 2 +- azalea-language/src/lib.rs | 10 +- azalea-physics/Cargo.toml | 2 +- azalea-physics/src/collision/blocks.rs | 3393 ++++++++++++------------ codegen/lib/code/shapes.py | 16 +- 12 files changed, 1745 insertions(+), 1755 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8d8b68e5..b7b73c49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,7 +194,7 @@ version = "0.3.0" dependencies = [ "azalea-buf", "azalea-language", - "lazy_static", + "once_cell", "serde", "serde_json", ] @@ -213,9 +213,9 @@ dependencies = [ "azalea-physics", "azalea-protocol", "azalea-world", - "lazy_static", "log", "nohash-hasher", + "once_cell", "parking_lot", "regex", "thiserror", @@ -253,7 +253,7 @@ dependencies = [ name = "azalea-language" version = "0.3.0" dependencies = [ - "lazy_static", + "once_cell", "serde", "serde_json", ] @@ -279,7 +279,7 @@ dependencies = [ "azalea-block", "azalea-core", "azalea-world", - "lazy_static", + "once_cell", "parking_lot", "uuid", ] diff --git a/azalea-chat/Cargo.toml b/azalea-chat/Cargo.toml index 7710a4c2..3fe28885 100755 --- a/azalea-chat/Cargo.toml +++ b/azalea-chat/Cargo.toml @@ -11,6 +11,6 @@ repository = "https://github.com/mat-1/azalea/tree/main/azalea-chat" [dependencies] azalea-buf = {path = "../azalea-buf", features = ["serde_json"], version = "^0.3.0" } azalea-language = {path = "../azalea-language", version = "^0.3.0" } -lazy_static = "^1.4.0" +once_cell = "1.16.0" serde = "^1.0.130" serde_json = "^1.0.72" diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs index e4c0ab72..882a521a 100755 --- a/azalea-chat/src/component.rs +++ b/azalea-chat/src/component.rs @@ -1,17 +1,16 @@ -use std::{ - fmt::Display, - io::{Cursor, Write}, -}; - -use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; -use serde::{de, Deserialize, Deserializer}; - use crate::{ base_component::BaseComponent, style::{ChatFormatting, Style}, text_component::TextComponent, translatable_component::{StringOrComponent, TranslatableComponent}, }; +use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; +use once_cell::sync::Lazy; +use serde::{de, Deserialize, Deserializer}; +use std::{ + fmt::Display, + io::{Cursor, Write}, +}; /// A chat component, basically anything you can see in chat. #[derive(Clone, Debug)] @@ -20,12 +19,10 @@ pub enum Component { Translatable(TranslatableComponent), } -lazy_static! { - pub static ref DEFAULT_STYLE: Style = Style { - color: Some(ChatFormatting::White.try_into().unwrap()), - ..Style::default() - }; -} +pub static DEFAULT_STYLE: Lazy