From 784111e22cc43d403fbc6703fa9a2a4c5c4fa3b5 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 19 Apr 2022 23:17:52 -0700 Subject: refactor(modules): move modules to module --- src/macros.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/macros.rs') 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 // SPDX-License-Identifier: GPL-3.0-only +use std::lazy::SyncLazy; + +pub static QUOTES: SyncLazy> = 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 = - 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"), -- cgit v1.2.3