aboutsummaryrefslogtreecommitdiff
path: root/azalea-language/src
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-language/src
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-language/src')
-rwxr-xr-xazalea-language/src/lib.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/azalea-language/src/lib.rs b/azalea-language/src/lib.rs
index b9905e54..468bcede 100755
--- a/azalea-language/src/lib.rs
+++ b/azalea-language/src/lib.rs
@@ -1,6 +1,6 @@
//! Translate Minecraft strings from their id.
-use lazy_static::lazy_static;
+use once_cell::sync::Lazy;
use std::io::Read;
use std::path::Path;
use std::{collections::HashMap, fs::File};
@@ -31,16 +31,16 @@ use std::{collections::HashMap, fs::File};
// Language object that we passed around everywhere which is not convenient
// The code above is kept in case I come up with a better solution
-lazy_static! {
- pub static ref STORAGE: HashMap<String, String> = serde_json::from_str(&{
+pub static STORAGE: Lazy<HashMap<String, String>> = Lazy::new(|| {
+ serde_json::from_str(&{
let src_dir = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/src/en_us.json"));
let mut file = File::open(src_dir).unwrap();
let mut contents = String::new();
file.read_to_string(&mut contents).unwrap();
contents
})
- .unwrap();
-}
+ .unwrap()
+});
pub fn get(key: &str) -> Option<&str> {
STORAGE.get(key).map(|s| s.as_str())