Skip to content

Commit f5eb848

Browse files
committed
remove dependency on lazy_static
This functionality was stabilized in std in Rust 1.80.
1 parent fe64396 commit f5eb848

File tree

4 files changed

+23
-28
lines changed

4 files changed

+23
-28
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ authors = ["The Rust Project Developers"]
55
edition = "2018"
66

77
[dependencies]
8-
lazy_static = "1.5.0"
98
fluent = "0.16"
109
fluent-bundle = "0.15.0"
1110
fluent-syntax = "0.11.0"

src/i18n.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rocket_dyn_templates::handlebars::{
33
};
44

55
use rocket::request::FromParam;
6-
use std::collections::HashSet;
6+
use std::{collections::HashSet, sync::LazyLock};
77

88
use handlebars_fluent::{
99
fluent_bundle::{concurrent::FluentBundle, FluentResource, FluentValue},
@@ -85,10 +85,9 @@ pub const EXPLICIT_LOCALE_INFO: &[LocaleInfo] = &[
8585
},
8686
];
8787

88-
lazy_static! {
89-
pub static ref SUPPORTED_LOCALES: HashSet<&'static str> =
90-
EXPLICIT_LOCALE_INFO.iter().map(|x| x.lang).collect();
91-
}
88+
pub static SUPPORTED_LOCALES: LazyLock<HashSet<&'static str>> =
89+
LazyLock::new(|| EXPLICIT_LOCALE_INFO.iter().map(|x| x.lang).collect());
90+
9291
pub struct TeamHelper {
9392
i18n: SimpleLoader,
9493
}

src/main.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#[macro_use]
2-
extern crate lazy_static;
31
extern crate reqwest;
42
extern crate serde_json;
53
#[macro_use]
@@ -38,6 +36,7 @@ use std::fs;
3836
use std::hash::Hasher;
3937
use std::path::{Path, PathBuf};
4038
use std::sync::Arc;
39+
use std::sync::LazyLock;
4140

4241
use rocket::{
4342
fs::NamedFile,
@@ -57,25 +56,24 @@ use i18n::{create_loader, LocaleInfo, SupportedLocale, TeamHelper, EXPLICIT_LOCA
5756

5857
const ZULIP_DOMAIN: &str = "https://rust-lang.zulipchat.com";
5958

60-
lazy_static! {
61-
static ref ASSETS: AssetFiles = {
62-
let app_css_file = compile_sass("app");
63-
let fonts_css_file = compile_sass("fonts");
64-
let vendor_css_file = concat_vendor_css(vec!["tachyons"]);
65-
let app_js_file = concat_app_js(vec!["tools-install"]);
66-
67-
AssetFiles {
68-
css: CSSFiles {
69-
app: app_css_file,
70-
fonts: fonts_css_file,
71-
vendor: vendor_css_file,
72-
},
73-
js: JSFiles { app: app_js_file },
74-
}
75-
};
76-
static ref PONTOON_ENABLED: bool = env::var("RUST_WWW_PONTOON").is_ok();
77-
static ref ROBOTS_TXT_DISALLOW_ALL: bool = env::var("ROBOTS_TXT_DISALLOW_ALL").is_ok();
78-
}
59+
static ASSETS: LazyLock<AssetFiles> = LazyLock::new(|| {
60+
let app_css_file = compile_sass("app");
61+
let fonts_css_file = compile_sass("fonts");
62+
let vendor_css_file = concat_vendor_css(vec!["tachyons"]);
63+
let app_js_file = concat_app_js(vec!["tools-install"]);
64+
65+
AssetFiles {
66+
css: CSSFiles {
67+
app: app_css_file,
68+
fonts: fonts_css_file,
69+
vendor: vendor_css_file,
70+
},
71+
js: JSFiles { app: app_js_file },
72+
}
73+
});
74+
static PONTOON_ENABLED: LazyLock<bool> = LazyLock::new(|| env::var("RUST_WWW_PONTOON").is_ok());
75+
static ROBOTS_TXT_DISALLOW_ALL: LazyLock<bool> =
76+
LazyLock::new(|| env::var("ROBOTS_TXT_DISALLOW_ALL").is_ok());
7977

8078
#[derive(Serialize)]
8179
struct Context<T: ::serde::Serialize> {

0 commit comments

Comments
 (0)