Skip to content

Commit

Permalink
Use std LazyLock
Browse files Browse the repository at this point in the history
  • Loading branch information
Berrysoft committed Jul 25, 2024
1 parent e63c691 commit 7bbb82a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ tunet-helper = { path = "tunet-helper" }
tunet-model = { path = "tunet-model" }
tunet-settings = { path = "tunet-settings" }

once_cell = "1"

anyhow = "1"
cfg-if = "1"
enum_dispatch = "0.3"
Expand Down
1 change: 0 additions & 1 deletion tunet-gui/ui/about.slint
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export global AboutModel {
[ { text: "netlink_wi" }, { text: "MIT"} ],
[ { text: "notify-rust" }, { text: "MIT"} ],
[ { text: "objc" }, { text: "MIT"} ],
[ { text: "once_cell" }, { text: "MIT"} ],
[ { text: "paste" }, { text: "MIT"} ],
[ { text: "plist" }, { text: "MIT"} ],
[ { text: "plotters" }, { text: "MIT"} ],
Expand Down
1 change: 0 additions & 1 deletion tunet-helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ serde_json = { workspace = true }
select = "0.6"
chrono = { workspace = true }
mac_address2 = { workspace = true }
once_cell = { workspace = true }
regex = { version = "1", default-features = false, features = ["std"] }
thiserror = { workspace = true }
allo-isolate = { version = "0.1", features = ["chrono"], optional = true }
Expand Down
7 changes: 4 additions & 3 deletions tunet-helper/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use base64::{
use data_encoding::HEXLOWER;
use hmac::{Hmac, Mac};
use md5::Md5;
use once_cell::sync::Lazy;
use regex::Regex;
use serde_json::{json, Value as JsonValue};
use sha1::{Digest, Sha1};
use std::marker::PhantomData;
use std::sync::LazyLock;
use url::Url;

#[derive(Clone)]
Expand All @@ -21,15 +21,16 @@ pub struct AuthConnect<U: AuthConnectUri + Send + Sync> {
_p: PhantomData<U>,
}

pub static AUTH_BASE64: Lazy<GeneralPurpose> = Lazy::new(|| {
pub static AUTH_BASE64: LazyLock<GeneralPurpose> = LazyLock::new(|| {
let alphabet =
Alphabet::new("LVoJPiCN2R8G90yg+hmFHuacZ1OWMnrsSTXkYpUq/3dlbfKwv6xztjI7DeBE45QA").unwrap();
GeneralPurpose::new(&alphabet, PAD)
});

static REDIRECT_URI: &str = "http://www.tsinghua.edu.cn/";

static AC_ID_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"/index_([0-9]+)\.html").unwrap());
static AC_ID_REGEX: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"/index_([0-9]+)\.html").unwrap());

impl<U: AuthConnectUri + Send + Sync> AuthConnect<U> {
pub fn new(client: HttpClient) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions tunet-helper/src/suggest/ssid_map.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{suggest::ping, *};
use netstatus::NetStatus;
use once_cell::sync::Lazy;
use std::collections::BTreeMap;
use std::sync::LazyLock;

static SUGGEST_SSID_MAP: Lazy<BTreeMap<&'static str, NetState>> = Lazy::new(|| {
static SUGGEST_SSID_MAP: LazyLock<BTreeMap<&'static str, NetState>> = LazyLock::new(|| {
BTreeMap::from([
("Tsinghua", NetState::Auth4),
("Tsinghua-5G", NetState::Auth4),
Expand Down

0 comments on commit 7bbb82a

Please sign in to comment.