diff options
| author | Fuwn <[email protected]> | 2022-04-19 23:17:52 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-04-19 23:17:52 -0700 |
| commit | 784111e22cc43d403fbc6703fa9a2a4c5c4fa3b5 (patch) | |
| tree | 3d8dd3b0e562bac1becc3ccd70835259be34765f /src/macros.rs | |
| parent | fix(docker): permissions, cba (diff) | |
| download | locus-784111e22cc43d403fbc6703fa9a2a4c5c4fa3b5.tar.xz locus-784111e22cc43d403fbc6703fa9a2a4c5c4fa3b5.zip | |
refactor(modules): move modules to module
Diffstat (limited to 'src/macros.rs')
| -rw-r--r-- | src/macros.rs | 15 |
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(); - - "es.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"), |