Skip to content

Commit

Permalink
⚡️ 更改lazy为标准库中lazylock
Browse files Browse the repository at this point in the history
  • Loading branch information
phidiaLam committed Nov 9, 2024
1 parent 08ff9d0 commit 399c249
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions libs/bitmap-convert/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ edition = "2021"
bitmaps.workspace = true
bnum = "0.5.0"
status-err = { version = "0.1.0", path = "../status-err" }
thiserror.workspace = true
once_cell = { workspace = true }
thiserror.workspace = true
11 changes: 6 additions & 5 deletions libs/bitmap-convert/src/base70.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use std::sync::LazyLock;

use bitmaps::Bitmap;
use bnum::types::U256;
use once_cell::sync::Lazy;

use crate::error::Error;

const BASE_70: &str =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~._()!*";
// 字符转下标
static CHAR_TO_INDEX: Lazy<[u8; 127]> = Lazy::new(|| {
static CHAR_TO_INDEX: LazyLock<[u8; 127]> = LazyLock::new(|| {
let mut char_to_index: [u8; 127] = [0; 127];
let index_to_char = BASE_70.chars().collect::<Vec<char>>();
for (i, c) in index_to_char.iter().enumerate() {
Expand All @@ -16,10 +17,10 @@ static CHAR_TO_INDEX: Lazy<[u8; 127]> = Lazy::new(|| {
char_to_index
});
// 下标转字符
static INDEX_TO_CHAR: Lazy<Vec<char>> =
Lazy::new(|| BASE_70.chars().collect());
static INDEX_TO_CHAR: LazyLock<Vec<char>> =
LazyLock::new(|| BASE_70.chars().collect());
// 字符数量
static RADIX: Lazy<u32> = Lazy::new(|| INDEX_TO_CHAR.len() as u32);
static RADIX: LazyLock<u32> = LazyLock::new(|| INDEX_TO_CHAR.len() as u32);

pub trait BitmapBase70Conv {
type Error;
Expand Down

0 comments on commit 399c249

Please sign in to comment.