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 <me@prma.dev>
This commit is contained in:
Perma Alesheikh 2024-01-08 21:30:15 +03:30 committed by Clément DOUIN
parent d2ad386eaa
commit 3cca9ac9e8
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72

View file

@ -17,18 +17,18 @@ use crate::{
printer::Printer,
};
const MAIN_PROGRESS_STYLE: Lazy<ProgressStyle> = Lazy::new(|| {
static MAIN_PROGRESS_STYLE: Lazy<ProgressStyle> = Lazy::new(|| {
ProgressStyle::with_template(" {spinner:.dim} {msg:.dim}\n {wide_bar:.cyan/blue} \n").unwrap()
});
const SUB_PROGRESS_STYLE: Lazy<ProgressStyle> = Lazy::new(|| {
static SUB_PROGRESS_STYLE: Lazy<ProgressStyle> = Lazy::new(|| {
ProgressStyle::with_template(
" {prefix:.bold} — {wide_msg:.dim} \n {wide_bar:.black/black} {percent}% ",
)
.unwrap()
});
const SUB_PROGRESS_DONE_STYLE: Lazy<ProgressStyle> = Lazy::new(|| {
static SUB_PROGRESS_DONE_STYLE: Lazy<ProgressStyle> = Lazy::new(|| {
ProgressStyle::with_template(" {prefix:.bold} \n {wide_bar:.green} {percent}% ").unwrap()
});