Skip to content

Commit 15c0b1f

Browse files
committed
Move statics to local scope
1 parent 10950f1 commit 15c0b1f

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

src/config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ use serenity::model::id::{ChannelId, GuildId, RoleId};
66
use std::fs::File;
77
use std::sync::{Arc, OnceLock, RwLock};
88

9-
static CONFIG: OnceLock<RwLock<Arc<Config>>> = OnceLock::new();
10-
119
fn writable_config() -> &'static RwLock<Arc<Config>> {
10+
static CONFIG: OnceLock<RwLock<Arc<Config>>> = OnceLock::new();
1211
CONFIG.get_or_init(|| RwLock::new(Arc::new(Config::load().unwrap())))
1312
}
1413

src/discord_bot/guild_storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use std::collections::{HashMap, HashSet};
1313
use std::ops::{Deref, DerefMut};
1414
use std::sync::OnceLock;
1515

16-
static GUILD_STORAGE: OnceLock<DashMap<GuildId, GuildStorage>> = OnceLock::new();
1716
fn guild_storage() -> &'static DashMap<GuildId, GuildStorage> {
17+
static GUILD_STORAGE: OnceLock<DashMap<GuildId, GuildStorage>> = OnceLock::new();
1818
GUILD_STORAGE.get_or_init(DashMap::new)
1919
}
2020

src/discord_bot/simple_words.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use serenity::model::user::User;
55
use std::collections::HashSet;
66
use std::sync::OnceLock;
77

8-
static TOP_10K_WORDS: OnceLock<HashSet<&'static str>> = OnceLock::new();
98
fn top_10k_words() -> &'static HashSet<&'static str> {
9+
static TOP_10K_WORDS: OnceLock<HashSet<&'static str>> = OnceLock::new();
1010
TOP_10K_WORDS.get_or_init(|| {
1111
let mut set = HashSet::with_capacity(5000);
1212
for word in include!("simple_writer_words.txt") {

src/discord_bot/update_copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use std::sync::OnceLock;
1111
use std::time::Duration;
1212
use tokio::sync::Mutex;
1313

14-
static COPY_UPDATE_MUTEX: OnceLock<Mutex<()>> = OnceLock::new();
1514
fn copy_update_mutex() -> &'static Mutex<()> {
15+
static COPY_UPDATE_MUTEX: OnceLock<Mutex<()>> = OnceLock::new();
1616
COPY_UPDATE_MUTEX.get_or_init(|| Mutex::new(()))
1717
}
1818

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pub struct ProtobotData {
5151
}
5252

5353
static IS_SHUTDOWN: AtomicBool = AtomicBool::new(false);
54-
static SHUTDOWN_SEMAPHORE: OnceLock<Semaphore> = OnceLock::new();
5554
fn shutdown_semaphore() -> &'static Semaphore {
55+
static SHUTDOWN_SEMAPHORE: OnceLock<Semaphore> = OnceLock::new();
5656
SHUTDOWN_SEMAPHORE.get_or_init(|| Semaphore::new(0))
5757
}
5858

0 commit comments

Comments
 (0)