Skip to content

Commit ad7c251

Browse files
authored
Merge pull request #5044 from Turbo87/lazy
Replace `lazy_static` with `once_cell`
2 parents 8d648be + ac71ef2 commit ad7c251

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ cargo-registry-index = { path = "cargo-registry-index", features = ["testing"] }
8989
claim = { git = "https://github.com/Turbo87/rust-claim.git", rev = "23892a3" }
9090
conduit-test = "=0.10.0"
9191
hyper-tls = "=0.5.0"
92-
lazy_static = "=1.4.0"
92+
once_cell = "=1.13.0"
9393
tokio = "=1.20.1"
9494
tower-service = "=0.3.2"
9595

src/tests/all.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ extern crate claim;
55
#[macro_use]
66
extern crate diesel;
77
#[macro_use]
8-
extern crate lazy_static;
9-
#[macro_use]
108
extern crate serde;
119
#[macro_use]
1210
extern crate serde_json;

src/tests/builders/publish.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ use cargo_registry::views::krate_publish as u;
22
use std::{collections::HashMap, io::Read};
33

44
use flate2::{write::GzEncoder, Compression};
5+
use once_cell::sync::Lazy;
56

67
use super::DependencyBuilder;
78

8-
lazy_static! {
9-
// The bytes of an empty tarball is not an empty vector of bytes because of tarball headers.
10-
// Unless files are added to a PublishBuilder, the `.crate` tarball that gets uploaded
11-
// will be empty, so precompute the empty tarball bytes to use as a default.
12-
static ref EMPTY_TARBALL_BYTES: Vec<u8> = {
13-
let mut empty_tarball = vec![];
14-
{
15-
let mut ar =
16-
tar::Builder::new(GzEncoder::new(&mut empty_tarball, Compression::default()));
17-
assert_ok!(ar.finish());
18-
}
19-
empty_tarball
20-
};
9+
// The bytes of an empty tarball is not an empty vector of bytes because of tarball headers.
10+
// Unless files are added to a PublishBuilder, the `.crate` tarball that gets uploaded
11+
// will be empty, so precompute the empty tarball bytes to use as a default.
12+
static EMPTY_TARBALL_BYTES: Lazy<Vec<u8>> = Lazy::new(generate_empty_tarball);
13+
14+
fn generate_empty_tarball() -> Vec<u8> {
15+
let mut empty_tarball = vec![];
16+
{
17+
let mut ar = tar::Builder::new(GzEncoder::new(&mut empty_tarball, Compression::default()));
18+
assert_ok!(ar.finish());
19+
}
20+
empty_tarball
2121
}
2222

2323
/// A builder for constructing a crate for the purposes of testing publishing. If you only need

0 commit comments

Comments
 (0)