Skip to content

Commit

Permalink
Fix file_release clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
exincore committed Jul 17, 2022
1 parent 7d86cae commit b9cf38d
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions os_info/src/linux/file_release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ fn retrieve(distributions: &[ReleaseInfo]) -> Option<Info> {
let os_type = (release_info.os_type)(&file_content);

// If os_type is indeterminate, try the next release_info
if let None = os_type {
if os_type.is_none() {
continue;
}

let version = (release_info.version)(&file_content);

return Some(Info {
os_type: os_type.unwrap(),
version: version.unwrap_or_else(|| Version::Unknown),
version: version.unwrap_or(Version::Unknown),
bitness: Bitness::Unknown,
..Default::default()
});
Expand Down Expand Up @@ -121,7 +121,7 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
Matcher::PrefixedVersion {
prefix: "CBL-Mariner",
}
.find(&release)
.find(release)
.map(Version::from_string)
},
},
Expand All @@ -130,7 +130,7 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
os_type: |_| Some(Type::CentOS),
version: |release| {
Matcher::PrefixedVersion { prefix: "release" }
.find(&release)
.find(release)
.map(Version::from_string)
},
},
Expand All @@ -139,23 +139,23 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
os_type: |_| Some(Type::Fedora),
version: |release| {
Matcher::PrefixedVersion { prefix: "release" }
.find(&release)
.find(release)
.map(Version::from_string)
},
},
ReleaseInfo {
path: "/etc/alpine-release",
os_type: |_| Some(Type::Alpine),
version: |release| Matcher::AllTrimmed.find(&release).map(Version::from_string),
version: |release| Matcher::AllTrimmed.find(release).map(Version::from_string),
},
// TODO: This should be placed first, as most modern distributions
// will have this file.
ReleaseInfo {
path: "/etc/os-release",
os_type: |release| {
Matcher::KeyValue { key: "ID" }
.find(&release)
.map(|id| match id.as_str() {
.find(release)
.and_then(|id| match id.as_str() {
// os-release information collected from
// https://github.com/chef/os_release

Expand Down Expand Up @@ -206,11 +206,10 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
//"xenserver" => xcp-ng
_ => None,
})
.flatten()
},
version: |release| {
Matcher::KeyValue { key: "VERSION_ID" }
.find(&release)
.find(release)
.map(Version::from_string)
},
},
Expand All @@ -219,7 +218,7 @@ static DISTRIBUTIONS: [ReleaseInfo; 6] = [
os_type: |_| Some(Type::RedHatEnterprise),
version: |release| {
Matcher::PrefixedVersion { prefix: "release" }
.find(&release)
.find(release)
.map(Version::from_string)
},
},
Expand Down

0 comments on commit b9cf38d

Please sign in to comment.