Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
refactor(disks): no need to Collect
Browse files Browse the repository at this point in the history
  • Loading branch information
eatradish committed Jan 10, 2024
1 parent b2fff5d commit 3dcfac4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,12 @@ pub fn mbr_is_primary_partition(

for mut device in libparted::Device::devices(true) {
if let Ok(disk) = libparted::Disk::new(&mut device) {
let parts = disk.parts().collect::<Vec<_>>();
let index = parts
.iter()
.position(|x| x.get_path() == part_path)
let mut parts = disk.parts();
let part = parts
.find(|x| x.get_path() == part_path)
.ok_or_else(|| anyhow!("Can not find select partition!"))?;

let part_type = parts[index].type_get_name();
let part_type = part.type_get_name();

if part_type != "primary" {
return Err(anyhow!(MBR_NON_PRIMARY_PART_ERROR));
Expand Down

0 comments on commit 3dcfac4

Please sign in to comment.