Fix clippy::unnecessary::filter-map warning

This commit is contained in:
Sergey Smirnykh 2020-04-21 14:48:56 +07:00 committed by Victor Berger
parent a774d8c52e
commit a5cd2978b3
1 changed files with 7 additions and 10 deletions

View File

@ -176,22 +176,19 @@ pub fn primary_gpu<S: AsRef<str>>(seat: S) -> IoResult<Option<PathBuf>> {
if let Some(path) = enumerator if let Some(path) = enumerator
.scan_devices()? .scan_devices()?
.filter_map(|device| { .filter(|device| {
if device let seat_name = device
.property_value("ID_SEAT") .property_value("ID_SEAT")
.map(|x| x.to_os_string()) .map(|x| x.to_os_string())
.unwrap_or_else(|| OsString::from("seat0")) .unwrap_or_else(|| OsString::from("seat0"));
== *seat.as_ref() if seat_name == *seat.as_ref() {
{
if let Ok(Some(pci)) = device.parent_with_subsystem(Path::new("pci")) { if let Ok(Some(pci)) = device.parent_with_subsystem(Path::new("pci")) {
if let Some(id) = pci.attribute_value("boot_vga") { if let Some(id) = pci.attribute_value("boot_vga") {
if id == "1" { return id == "1";
return Some(device);
}
} }
} }
}; }
None false
}) })
.flat_map(|device| device.devnode().map(PathBuf::from)) .flat_map(|device| device.devnode().map(PathBuf::from))
.next() .next()