From 3cca9ac9e8ad5c694aa032cda48a3cf6262a3bb7 Mon Sep 17 00:00:00 2001 From: Perma Alesheikh Date: Mon, 8 Jan 2024 21:30:15 +0330 Subject: [PATCH] use static instead of const for lazy values Reasons: - Every time a const is referenced, a new instance of the Cell, Mutex, or AtomicXxxx is created, negating the purpose of using these types. To address this issue, the const value should be stored within a static item. Signed-off-by: Perma Alesheikh --- src/account/command/sync.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/account/command/sync.rs b/src/account/command/sync.rs index fc5d5d0..cf5bc9f 100644 --- a/src/account/command/sync.rs +++ b/src/account/command/sync.rs @@ -17,18 +17,18 @@ use crate::{ printer::Printer, }; -const MAIN_PROGRESS_STYLE: Lazy = Lazy::new(|| { +static MAIN_PROGRESS_STYLE: Lazy = Lazy::new(|| { ProgressStyle::with_template(" {spinner:.dim} {msg:.dim}\n {wide_bar:.cyan/blue} \n").unwrap() }); -const SUB_PROGRESS_STYLE: Lazy = Lazy::new(|| { +static SUB_PROGRESS_STYLE: Lazy = Lazy::new(|| { ProgressStyle::with_template( " {prefix:.bold} — {wide_msg:.dim} \n {wide_bar:.black/black} {percent}% ", ) .unwrap() }); -const SUB_PROGRESS_DONE_STYLE: Lazy = Lazy::new(|| { +static SUB_PROGRESS_DONE_STYLE: Lazy = Lazy::new(|| { ProgressStyle::with_template(" {prefix:.bold} \n {wide_bar:.green} {percent}% ").unwrap() });