aboutsummaryrefslogtreecommitdiff
path: root/src/macros.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-19 23:17:52 -0700
committerFuwn <[email protected]>2022-04-19 23:17:52 -0700
commit784111e22cc43d403fbc6703fa9a2a4c5c4fa3b5 (patch)
tree3d8dd3b0e562bac1becc3ccd70835259be34765f /src/macros.rs
parentfix(docker): permissions, cba (diff)
downloadlocus-784111e22cc43d403fbc6703fa9a2a4c5c4fa3b5.tar.xz
locus-784111e22cc43d403fbc6703fa9a2a4c5c4fa3b5.zip
refactor(modules): move modules to module
Diffstat (limited to 'src/macros.rs')
-rw-r--r--src/macros.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/macros.rs b/src/macros.rs
index bfaf9c2..7dd6048 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -16,6 +16,12 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
+use std::lazy::SyncLazy;
+
+pub static QUOTES: SyncLazy<Vec<String>> = SyncLazy::new(|| {
+ serde_json::from_str(include_str!("../content/json/quotes.json")).unwrap()
+});
+
#[macro_export]
macro_rules! success {
($body:expr, $context:ident) => {{
@@ -28,11 +34,10 @@ macro_rules! success {
quote: {
use rand::seq::SliceRandom;
- let quotes: Vec<String> =
- serde_json::from_str(include_str!("../content/json/quotes.json"))
- .unwrap();
-
- &quotes.choose(&mut rand::thread_rng()).unwrap().to_string()
+ &$crate::macros::QUOTES
+ .choose(&mut rand::thread_rng())
+ .unwrap()
+ .to_string()
},
commit: &format!("/tree/{}", env!("VERGEN_GIT_SHA")),
mini_commit: env!("VERGEN_GIT_SHA").get(0..5).unwrap_or("UNKNOWN"),