From 399c249ef9b0b003c070916a32ba94926d203bd1 Mon Sep 17 00:00:00 2001 From: phidiaLam <2957035701@qq.com> Date: Sun, 10 Nov 2024 02:36:40 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20=E6=9B=B4=E6=94=B9lazy?= =?UTF-8?q?=E4=B8=BA=E6=A0=87=E5=87=86=E5=BA=93=E4=B8=ADlazylock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/bitmap-convert/Cargo.toml | 3 +-- libs/bitmap-convert/src/base70.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libs/bitmap-convert/Cargo.toml b/libs/bitmap-convert/Cargo.toml index 460929ba2..cd9df06a6 100644 --- a/libs/bitmap-convert/Cargo.toml +++ b/libs/bitmap-convert/Cargo.toml @@ -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 } \ No newline at end of file +thiserror.workspace = true \ No newline at end of file diff --git a/libs/bitmap-convert/src/base70.rs b/libs/bitmap-convert/src/base70.rs index c302a540c..0b56f5c42 100644 --- a/libs/bitmap-convert/src/base70.rs +++ b/libs/bitmap-convert/src/base70.rs @@ -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::>(); for (i, c) in index_to_char.iter().enumerate() { @@ -16,10 +17,10 @@ static CHAR_TO_INDEX: Lazy<[u8; 127]> = Lazy::new(|| { char_to_index }); // 下标转字符 -static INDEX_TO_CHAR: Lazy> = - Lazy::new(|| BASE_70.chars().collect()); +static INDEX_TO_CHAR: LazyLock> = + LazyLock::new(|| BASE_70.chars().collect()); // 字符数量 -static RADIX: Lazy = Lazy::new(|| INDEX_TO_CHAR.len() as u32); +static RADIX: LazyLock = LazyLock::new(|| INDEX_TO_CHAR.len() as u32); pub trait BitmapBase70Conv { type Error;