mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-12-04 15:36:30 +00:00
refactor: replace once_cell with std equivalents (#242)
This commit is contained in:
parent
3a2e134c40
commit
c27c8ea184
6 changed files with 8 additions and 13 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -376,7 +376,6 @@ name = "badge"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"once_cell",
|
|
||||||
"rusttype",
|
"rusttype",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
|
@ -3590,7 +3589,6 @@ dependencies = [
|
||||||
"lru_time_cache",
|
"lru_time_cache",
|
||||||
"maud",
|
"maud",
|
||||||
"mime",
|
"mime",
|
||||||
"once_cell",
|
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pulldown-cmark",
|
"pulldown-cmark",
|
||||||
"relative-path",
|
"relative-path",
|
||||||
|
|
|
@ -29,7 +29,6 @@ indexmap = { version = "2", features = ["serde"] }
|
||||||
lru_time_cache = "0.11"
|
lru_time_cache = "0.11"
|
||||||
maud = "0.26"
|
maud = "0.26"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
once_cell = "1"
|
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12"
|
||||||
pulldown-cmark = "0.12"
|
pulldown-cmark = "0.12"
|
||||||
relative-path = { version = "1", features = ["serde"] }
|
relative-path = { version = "1", features = ["serde"] }
|
||||||
|
|
|
@ -13,7 +13,6 @@ path = "badge.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = "0.22"
|
base64 = "0.22"
|
||||||
once_cell = "1"
|
|
||||||
rusttype = "0.9"
|
rusttype = "0.9"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
//! Simple badge generator
|
//! Simple badge generator
|
||||||
|
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use base64::display::Base64Display;
|
use base64::display::Base64Display;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use rusttype::{point, Font, Point, PositionedGlyph, Scale};
|
use rusttype::{point, Font, Point, PositionedGlyph, Scale};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ struct BadgeStaticData {
|
||||||
offset: Point<f32>,
|
offset: Point<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
static DATA: Lazy<BadgeStaticData> = Lazy::new(|| {
|
static DATA: LazyLock<BadgeStaticData> = LazyLock::new(|| {
|
||||||
let font = Font::try_from_bytes(FONT_DATA).expect("failed to parse font collection");
|
let font = Font::try_from_bytes(FONT_DATA).expect("failed to parse font collection");
|
||||||
|
|
||||||
let v_metrics = font.v_metrics(SCALE);
|
let v_metrics = font.v_metrics(SCALE);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
panic::RefUnwindSafe,
|
panic::RefUnwindSafe,
|
||||||
sync::Arc,
|
sync::{Arc, LazyLock},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ use futures_util::{
|
||||||
stream::{self, LocalBoxStream},
|
stream::{self, LocalBoxStream},
|
||||||
StreamExt as _,
|
StreamExt as _,
|
||||||
};
|
};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use relative_path::{RelativePath, RelativePathBuf};
|
use relative_path::{RelativePath, RelativePathBuf};
|
||||||
use rustsec::database::Database;
|
use rustsec::database::Database;
|
||||||
use semver::VersionReq;
|
use semver::VersionReq;
|
||||||
|
@ -296,7 +295,7 @@ async fn resolve_crate_with_engine(
|
||||||
Ok(crate_res.releases)
|
Ok(crate_res.releases)
|
||||||
}
|
}
|
||||||
|
|
||||||
static POPULAR_REPO_BLOCK_LIST: Lazy<HashSet<RepoPath>> = Lazy::new(|| {
|
static POPULAR_REPO_BLOCK_LIST: LazyLock<HashSet<RepoPath>> = LazyLock::new(|| {
|
||||||
vec![
|
vec![
|
||||||
RepoPath::from_parts("github", "rust-lang", "rust"),
|
RepoPath::from_parts("github", "rust-lang", "rust"),
|
||||||
RepoPath::from_parts("github", "xi-editor", "xi-editor"),
|
RepoPath::from_parts("github", "xi-editor", "xi-editor"),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::env;
|
use std::{env, sync::LazyLock};
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
get,
|
get,
|
||||||
|
@ -16,7 +16,6 @@ use actix_web_lab::{
|
||||||
use assets::STATIC_FAVICON_PATH;
|
use assets::STATIC_FAVICON_PATH;
|
||||||
use badge::BadgeStyle;
|
use badge::BadgeStyle;
|
||||||
use futures_util::future;
|
use futures_util::future;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use semver::VersionReq;
|
use semver::VersionReq;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
@ -304,8 +303,8 @@ pub(crate) async fn not_found() -> impl Responder {
|
||||||
Html::new(views::html::error::render_404().0)
|
Html::new(views::html::error::render_404().0)
|
||||||
}
|
}
|
||||||
|
|
||||||
static SELF_BASE_URL: Lazy<String> =
|
static SELF_BASE_URL: LazyLock<String> =
|
||||||
Lazy::new(|| env::var("BASE_URL").unwrap_or_else(|_| "http://localhost:8080".to_string()));
|
LazyLock::new(|| env::var("BASE_URL").unwrap_or_else(|_| "http://localhost:8080".to_string()));
|
||||||
|
|
||||||
/// Configuration options supplied through Get Parameters
|
/// Configuration options supplied through Get Parameters
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
|
Loading…
Reference in a new issue