diff --git a/Cargo.toml b/Cargo.toml index d76abcd2..b25ac28b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ name = "update_and_get_most_recent_version" required-features = ["git-https"] [dependencies] -gix = { version = "0.73.0", default-features = false, features = [ +gix = { version = "0.74.1", default-features = false, features = [ "max-performance-safe", "blocking-network-client", "revision", @@ -57,7 +57,7 @@ toml = { version = "0.9.0", default-features = false, features = ["parse", "serd document-features = { version = "0.2.0", optional = true } [dev-dependencies] -bytesize = "1.2.0" +bytesize = "2.1.0" cap = { version = "0.1.2", features = ["stats"] } is_ci = "1.1.1" tempfile = "3.5.0" diff --git a/examples/list_recent_versions.rs b/examples/list_recent_versions.rs index 82a8da35..5dac5be4 100644 --- a/examples/list_recent_versions.rs +++ b/examples/list_recent_versions.rs @@ -69,9 +69,7 @@ fn fetch_crate(name: &str, sparse_index: &SparseIndex) -> Result, } fn names(name: &str) -> Result, Box> { - Ok(Names::new(name) - .ok_or_else(|| "Too many hyphens in crate name")? - .take(3)) + Ok(Names::new(name).ok_or("Too many hyphens in crate name")?.take(3)) } /// Create a request to the sparse `index` and parse the response with the side-effect of yielding diff --git a/examples/sparse_http_reqwest.rs b/examples/sparse_http_reqwest.rs index 5e47efa9..b19e2550 100644 --- a/examples/sparse_http_reqwest.rs +++ b/examples/sparse_http_reqwest.rs @@ -1,12 +1,12 @@ -use crates_index::SparseIndex; +//! +//! **important**:
+//! dont forget to enable the **["blocking", "gzip"]** feature of **reqwest** +//! +//! command to run:
+//! cargo run --example sparse_http_reqwest -F sparse +//! -/// -/// **important**:
-/// dont forget to enable the **["blocking", "gzip"]** feature of **reqwest** -/// -/// command to run:
-/// cargo run --example sparse_http_reqwest -F sparse -/// +use crates_index::SparseIndex; const CRATE_TO_FETCH: &str = "names"; diff --git a/examples/sparse_http_ureq.rs b/examples/sparse_http_ureq.rs index 237a4325..ed1a3eba 100644 --- a/examples/sparse_http_ureq.rs +++ b/examples/sparse_http_ureq.rs @@ -1,10 +1,9 @@ +//! +//! command to run:
+//! cargo run --example sparse_http_ureq -F sparse +//! use crates_index::SparseIndex; -/// -/// command to run:
-/// cargo run --example sparse_http_ureq -F sparse -/// - const CRATE_TO_FETCH: &str = "inferno"; fn main() { diff --git a/src/types.rs b/src/types.rs index ae3db790..c0ebcf8e 100644 --- a/src/types.rs +++ b/src/types.rs @@ -238,10 +238,11 @@ impl Dependency { } /// Section in which this dependency was defined -#[derive(Debug, Copy, Clone, Serialize, Deserialize, Eq, PartialEq, Hash)] +#[derive(Debug, Copy, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, Default)] #[serde(rename_all = "lowercase")] pub enum DependencyKind { /// Used at run time + #[default] Normal, /// Not fetched and not used, except for when used direclty in a workspace Dev, @@ -249,12 +250,6 @@ pub enum DependencyKind { Build, } -impl Default for DependencyKind { - fn default() -> Self { - Self::Normal - } -} - /// A whole crate with all its versions #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Crate { @@ -277,8 +272,7 @@ impl Crate { let num_versions = bytes.split(is_newline).count(); let mut versions = Vec::with_capacity(num_versions); for line in bytes.split(is_newline) { - let mut version: Version = - serde_json::from_slice(line).map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; + let mut version: Version = serde_json::from_slice(line).map_err(io::Error::other)?; version.build_data(dedupe); @@ -330,10 +324,7 @@ impl Crate { // the PR we explicitly tell the user their version of cargo is suspect // these versions are so old (and specific) it shouldn't affect really anyone 2 => { - return Err(io::Error::new( - io::ErrorKind::Other, - "potentially invalid version 2 cache entry found", - )); + return Err(io::Error::other("potentially invalid version 2 cache entry found")); } version => { return Err(io::Error::new( @@ -347,13 +338,10 @@ impl Crate { let update = iter.next().ok_or(io::ErrorKind::UnexpectedEof)?; if let Some(index_version) = index_version { if update != index_version.as_bytes() { - return Err(io::Error::new( - io::ErrorKind::Other, - format!( - "cache out of date: current index ({index_version}) != cache ({})", - String::from_utf8_lossy(update) - ), - )); + return Err(io::Error::other(format!( + "cache out of date: current index ({index_version}) != cache ({})", + String::from_utf8_lossy(update) + ))); } }