forked from gentoo-utils/gentoo-utils
fix clippy lints
This commit is contained in:
@@ -77,7 +77,7 @@ pub struct SlotName(#[get(method = "name", kind = "deref")] String);
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Get)]
|
||||
pub struct Slot {
|
||||
slot: Option<SlotName>,
|
||||
primary: Option<SlotName>,
|
||||
sub: Option<SlotName>,
|
||||
operator: Option<SlotOperator>,
|
||||
}
|
||||
@@ -134,6 +134,7 @@ pub struct Atom {
|
||||
}
|
||||
|
||||
impl Cpv {
|
||||
#[must_use]
|
||||
pub fn into_cp(self) -> Cp {
|
||||
Cp {
|
||||
name: self.name,
|
||||
@@ -143,13 +144,12 @@ impl Cpv {
|
||||
}
|
||||
|
||||
impl Atom {
|
||||
#[must_use]
|
||||
pub fn version_operator(&self) -> Option<VersionOperator> {
|
||||
match self.version {
|
||||
Some((operator, _)) => Some(operator),
|
||||
None => None,
|
||||
}
|
||||
self.version.clone().map(|(oper, _)| oper)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn into_cp(self) -> Cp {
|
||||
Cp {
|
||||
category: self.category,
|
||||
@@ -157,6 +157,7 @@ impl Atom {
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn into_cpv(self) -> Option<Cpv> {
|
||||
match self.version {
|
||||
Some((_, version)) => Some(Cpv {
|
||||
@@ -177,8 +178,7 @@ impl PartialEq for VersionSuffix {
|
||||
(Some(a), Some(b)) => a.0 == b.0,
|
||||
(Some(a), None) if a.get().chars().all(|c| c == '0') => true,
|
||||
(None, Some(b)) if b.get().chars().all(|c| c == '0') => true,
|
||||
(Some(_), None) => false,
|
||||
(None, Some(_)) => false,
|
||||
(Some(_), None) | (None, Some(_)) => false,
|
||||
(None, None) => true,
|
||||
}
|
||||
}
|
||||
@@ -220,10 +220,9 @@ impl PartialEq for VersionSuffixes {
|
||||
|
||||
loop {
|
||||
match (a.next(), b.next()) {
|
||||
(Some(a), Some(b)) if a == b => continue,
|
||||
(Some(_), Some(_)) => break false,
|
||||
(Some(a), Some(b)) if a == b => (),
|
||||
(Some(_) | None, Some(_)) | (Some(_), None) => break false,
|
||||
(None, None) => break true,
|
||||
_ => break false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,7 +246,7 @@ impl Ord for VersionSuffixes {
|
||||
(Some(a), Some(b)) => match a.cmp(b) {
|
||||
Ordering::Less => break Ordering::Less,
|
||||
Ordering::Greater => break Ordering::Greater,
|
||||
Ordering::Equal => continue,
|
||||
Ordering::Equal => (),
|
||||
},
|
||||
(Some(a), None) if matches!(a.kind, VersionSuffixKind::P) => {
|
||||
break Ordering::Greater;
|
||||
@@ -271,9 +270,9 @@ impl PartialEq for VersionNumbers {
|
||||
|
||||
loop {
|
||||
match (a.next(), b.next()) {
|
||||
(Some(a), Some(b)) if a.get().starts_with("0") => {
|
||||
let a = a.get().trim_end_matches("0");
|
||||
let b = b.get().trim_end_matches("0");
|
||||
(Some(a), Some(b)) if a.get().starts_with('0') => {
|
||||
let a = a.get().trim_end_matches('0');
|
||||
let b = b.get().trim_end_matches('0');
|
||||
|
||||
if a != b {
|
||||
break false;
|
||||
@@ -284,8 +283,8 @@ impl PartialEq for VersionNumbers {
|
||||
break false;
|
||||
}
|
||||
}
|
||||
(Some(a), None) if a.get().chars().all(|c| c == '0') => continue,
|
||||
(None, Some(b)) if b.get().chars().all(|c| c == '0') => continue,
|
||||
(Some(a), None) if a.get().chars().all(|c| c == '0') => (),
|
||||
(None, Some(b)) if b.get().chars().all(|c| c == '0') => (),
|
||||
(None, None) => break true,
|
||||
_ => break false,
|
||||
}
|
||||
@@ -313,8 +312,8 @@ impl Ord for VersionNumbers {
|
||||
.unwrap()
|
||||
.cmp(&other.get().first().unwrap().get().parse::<u64>().unwrap())
|
||||
{
|
||||
Ordering::Less => return Ordering::Less,
|
||||
Ordering::Greater => return Ordering::Greater,
|
||||
Ordering::Less => Ordering::Less,
|
||||
Ordering::Greater => Ordering::Greater,
|
||||
Ordering::Equal => {
|
||||
let mut a = self.get().iter().skip(1);
|
||||
let mut b = other.get().iter().skip(1);
|
||||
@@ -322,15 +321,15 @@ impl Ord for VersionNumbers {
|
||||
loop {
|
||||
match (a.next(), b.next()) {
|
||||
(Some(a), Some(b))
|
||||
if a.get().starts_with("0") || b.get().starts_with("0") =>
|
||||
if a.get().starts_with('0') || b.get().starts_with('0') =>
|
||||
{
|
||||
let a = a.get().trim_end_matches("0");
|
||||
let b = b.get().trim_end_matches("0");
|
||||
let a = a.get().trim_end_matches('0');
|
||||
let b = b.get().trim_end_matches('0');
|
||||
|
||||
match a.cmp(b) {
|
||||
Ordering::Less => break Ordering::Less,
|
||||
Ordering::Greater => break Ordering::Greater,
|
||||
Ordering::Equal => continue,
|
||||
Ordering::Equal => (),
|
||||
}
|
||||
}
|
||||
(Some(a), Some(b)) => match a
|
||||
@@ -341,7 +340,7 @@ impl Ord for VersionNumbers {
|
||||
{
|
||||
Ordering::Less => break Ordering::Less,
|
||||
Ordering::Greater => break Ordering::Greater,
|
||||
Ordering::Equal => continue,
|
||||
Ordering::Equal => (),
|
||||
},
|
||||
|
||||
(Some(_), None) => break Ordering::Greater,
|
||||
@@ -364,9 +363,8 @@ impl PartialEq for Version {
|
||||
a.get().parse::<u64>().unwrap() == b.get().parse::<u64>().unwrap()
|
||||
}
|
||||
(Some(a), None) if a.get().chars().all(|c| c == '0') => true,
|
||||
(Some(_), None) => false,
|
||||
(None, Some(b)) if b.get().chars().all(|c| c == '0') => true,
|
||||
(None, Some(_)) => false,
|
||||
(Some(_), None) | (None, Some(_)) => false,
|
||||
(None, None) => true,
|
||||
}
|
||||
}
|
||||
@@ -402,7 +400,7 @@ impl Ord for Version {
|
||||
(None, Some(_)) => return Ordering::Less,
|
||||
(None, None) => (),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
||||
match (&self.rev, &other.rev) {
|
||||
(Some(a), Some(b)) => a
|
||||
@@ -499,7 +497,7 @@ impl fmt::Display for Version {
|
||||
.numbers
|
||||
.get()
|
||||
.iter()
|
||||
.map(|n| n.get())
|
||||
.map(VersionNumber::get)
|
||||
.intersperse(".")
|
||||
.collect::<String>();
|
||||
|
||||
@@ -507,18 +505,18 @@ impl fmt::Display for Version {
|
||||
.suffixes
|
||||
.get()
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.map(VersionSuffix::to_string)
|
||||
.intersperse("_".to_string())
|
||||
.collect::<String>();
|
||||
|
||||
write!(f, "{}", numbers)?;
|
||||
write!(f, "{numbers}")?;
|
||||
|
||||
if let Some(letter) = self.letter {
|
||||
write!(f, "{letter}")?;
|
||||
}
|
||||
|
||||
if suffixes.len() > 0 {
|
||||
write!(f, "_{}", suffixes)?;
|
||||
if !suffixes.is_empty() {
|
||||
write!(f, "_{suffixes}")?;
|
||||
}
|
||||
|
||||
if let Some(rev) = self.rev.as_ref() {
|
||||
@@ -546,7 +544,7 @@ impl fmt::Display for SlotName {
|
||||
|
||||
impl fmt::Display for Slot {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if let Some(slot) = self.slot.as_ref() {
|
||||
if let Some(slot) = self.primary.as_ref() {
|
||||
write!(f, "{slot}")?;
|
||||
}
|
||||
|
||||
@@ -652,7 +650,7 @@ impl fmt::Display for Atom {
|
||||
let usedeps = self
|
||||
.usedeps
|
||||
.iter()
|
||||
.map(|u| u.to_string())
|
||||
.map(UseDep::to_string)
|
||||
.intersperse(",".to_string())
|
||||
.collect::<String>();
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ impl<'a> Parseable<'a, &'a str> for VersionNumbers {
|
||||
.map(|output: &str| VersionNumber(output.to_string()))
|
||||
.separated_by(tag("."))
|
||||
.at_least(1)
|
||||
.map(|numbers| VersionNumbers(numbers))
|
||||
.map(VersionNumbers)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ impl<'a> Parseable<'a, &'a str> for VersionSuffixes {
|
||||
VersionSuffix::parser()
|
||||
.separated_by(tag("_"))
|
||||
.at_least(1)
|
||||
.map(|suffixes| VersionSuffixes(suffixes))
|
||||
.map(VersionSuffixes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,8 +180,8 @@ impl<'a> Parseable<'a, &'a str> for Slot {
|
||||
.opt()
|
||||
.and(SlotName::parser().preceded_by(tag("/")).opt())
|
||||
.and(SlotOperator::parser().opt())
|
||||
.map(|((slot, sub), operator)| Slot {
|
||||
slot,
|
||||
.map(|((primary, sub), operator)| Slot {
|
||||
primary,
|
||||
sub,
|
||||
operator,
|
||||
})
|
||||
@@ -201,6 +201,7 @@ impl<'a> Parseable<'a, &'a str> for UseDepSign {
|
||||
impl<'a> Parseable<'a, &'a str> for UseDep {
|
||||
type Parser = impl Parser<&'a str, Output = Self>;
|
||||
|
||||
#[allow(clippy::many_single_char_names)]
|
||||
fn parser() -> Self::Parser {
|
||||
let a = UseFlag::parser()
|
||||
.and(UseDepSign::parser().opt())
|
||||
@@ -321,7 +322,7 @@ impl<'a> Parseable<'a, &'a str> for Atom {
|
||||
.numbers()
|
||||
.get()
|
||||
.iter()
|
||||
.any(|number| number.get().contains("*")) =>
|
||||
.any(|number| number.get().contains('*')) =>
|
||||
{
|
||||
true
|
||||
}
|
||||
@@ -414,7 +415,7 @@ mod test {
|
||||
fn test_invalid_usedep() {
|
||||
let it = InputIter::new("foo-bar:slot/sub=[!use]");
|
||||
|
||||
assert!(Atom::parser().check_finished(it).is_err())
|
||||
assert!(Atom::parser().check_finished(it).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user