diff --git a/Cargo.lock b/Cargo.lock index f4424a9..e6fd0ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -271,9 +271,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" dependencies = [ "rand_core", ] diff --git a/purl/src/format.rs b/purl/src/format.rs index 05f6aa6..56be75f 100644 --- a/purl/src/format.rs +++ b/purl/src/format.rs @@ -119,7 +119,7 @@ mod tests { impl PurlShape for MyBadPackageType { type Error = ParseError; - fn package_type(&self) -> Cow { + fn package_type(&self) -> Cow<'_, str> { Cow::Borrowed("!") } diff --git a/purl/src/lib.rs b/purl/src/lib.rs index a14f8d2..3d8fc01 100644 --- a/purl/src/lib.rs +++ b/purl/src/lib.rs @@ -1,5 +1,6 @@ #![doc = include_str!("../README.md")] -#![cfg_attr(docsrs, feature(doc_auto_cfg))] +#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, doc(auto_cfg))] use std::borrow::Cow; @@ -117,7 +118,7 @@ pub trait PurlShape { /// The returned value should be a lower case string. If the returned value /// contains invalid characters, `Display` and `to_string` will panic. #[must_use] - fn package_type(&self) -> Cow; + fn package_type(&self) -> Cow<'_, str>; /// Preview and potentially modify the parts that make up a PURL. /// @@ -136,7 +137,7 @@ pub trait PurlShape { impl PurlShape for String { type Error = ParseError; - fn package_type(&self) -> Cow { + fn package_type(&self) -> Cow<'_, str> { Cow::Borrowed(self) } @@ -155,7 +156,7 @@ impl PurlShape for String { impl PurlShape for Cow<'_, str> { type Error = ParseError; - fn package_type(&self) -> Cow { + fn package_type(&self) -> Cow<'_, str> { Cow::Borrowed(self) } @@ -188,7 +189,7 @@ where { type Error = ParseError; - fn package_type(&self) -> Cow { + fn package_type(&self) -> Cow<'_, str> { Cow::Borrowed(self) } diff --git a/purl/src/package_type.rs b/purl/src/package_type.rs index ce2f1f3..5b89954 100644 --- a/purl/src/package_type.rs +++ b/purl/src/package_type.rs @@ -243,7 +243,7 @@ impl From for PackageError { impl PurlShape for PackageType { type Error = PackageError; - fn package_type(&self) -> Cow { + fn package_type(&self) -> Cow<'_, str> { self.name().into() } diff --git a/purl/src/parse.rs b/purl/src/parse.rs index a13f5bb..4e05336 100644 --- a/purl/src/parse.rs +++ b/purl/src/parse.rs @@ -297,7 +297,7 @@ fn decode_namespace(namespace: &str) -> Result { Ok(rebuilt) } -fn decode(input: &str) -> Result, ParseError> { +fn decode(input: &str) -> Result, ParseError> { percent_decode_str(input).decode_utf8().map_err(|_| ParseError::InvalidEscape) } diff --git a/purl/src/qualifiers.rs b/purl/src/qualifiers.rs index 84472ea..0e1bd60 100644 --- a/purl/src/qualifiers.rs +++ b/purl/src/qualifiers.rs @@ -63,14 +63,14 @@ impl Qualifiers { } /// Iterate over the elements of the list. - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_> { Iter(self.qualifiers.iter()) } /// Iterate over the elements of the list. /// /// Only the value may be mutated. - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_> { IterMut(self.qualifiers.iter_mut()) } @@ -159,7 +159,7 @@ impl Qualifiers { /// This allows obtaining the current value and modifying it or inserting a /// new value without needing to search for the qualifier multiple /// times. - pub fn entry(&mut self, key: K) -> Result, ParseError> + pub fn entry(&mut self, key: K) -> Result, ParseError> where K: AsRef, { diff --git a/purl/src/qualifiers/well_known.rs b/purl/src/qualifiers/well_known.rs index 64d04b5..4c2ff98 100644 --- a/purl/src/qualifiers/well_known.rs +++ b/purl/src/qualifiers/well_known.rs @@ -216,7 +216,7 @@ impl Checksum<'_> { /// Iterate over the hashes. /// /// Hashes are returned in no particular order. - pub fn iter(&self) -> ChecksumIter { + pub fn iter(&self) -> ChecksumIter<'_> { ChecksumIter(self.algorithms.iter()) } } diff --git a/purl_test/src/lib.rs b/purl_test/src/lib.rs index c75f060..6cb5885 100644 --- a/purl_test/src/lib.rs +++ b/purl_test/src/lib.rs @@ -1,6 +1,7 @@ // This file is autogenerated by generate_tests.rs. // Use `cargo xtask codegen` to regenerate it. #![cfg(test)] +#![allow(clippy::needless_question_mark)] use std::str::FromStr; diff --git a/xtask/src/generate_tests.rs b/xtask/src/generate_tests.rs index c025b39..4fb404d 100644 --- a/xtask/src/generate_tests.rs +++ b/xtask/src/generate_tests.rs @@ -83,6 +83,8 @@ pub fn main() { writeln!(file, "// This file is autogenerated by generate_tests.rs.").unwrap(); writeln!(file, "// Use `cargo xtask codegen` to regenerate it.").unwrap(); writeln!(file, "#![cfg(test)]").unwrap(); + // Sometimes it is needed and sometimes it isn't. + writeln!(file, "#![allow(clippy::needless_question_mark)]").unwrap(); writeln!(file).unwrap(); writeln!(file, "{}", prettyplease::unparse(&suite)).unwrap(); }