block: raw: Use map_or instead of map().unwrap_or()

Do the necessary replacements to satisfy clippy::map_unwrap_or.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-05 22:59:03 +01:00
committed by Rob Bradford
parent 5925a013af
commit b7b38df99c
3 changed files with 6 additions and 9 deletions

View File

@@ -42,9 +42,8 @@ impl DiskFile for RawFileDisk {
fn new_async_io(&self, ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
let mut raw = RawFileAsync::new(self.file.as_raw_fd(), ring_depth)
.map_err(DiskFileError::NewAsyncIo)?;
raw.alignment = DiskTopology::probe(&self.file)
.map(|t| t.logical_block_size)
.unwrap_or(SECTOR_SIZE);
raw.alignment =
DiskTopology::probe(&self.file).map_or(SECTOR_SIZE, |t| t.logical_block_size);
Ok(Box::new(raw) as Box<dyn AsyncIo>)
}

View File

@@ -45,9 +45,8 @@ impl DiskFile for RawFileDiskAio {
fn new_async_io(&self, ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
let mut raw = RawFileAsyncAio::new(self.file.as_raw_fd(), ring_depth)
.map_err(DiskFileError::NewAsyncIo)?;
raw.alignment = DiskTopology::probe(&self.file)
.map(|t| t.logical_block_size)
.unwrap_or(SECTOR_SIZE);
raw.alignment =
DiskTopology::probe(&self.file).map_or(SECTOR_SIZE, |t| t.logical_block_size);
Ok(Box::new(raw) as Box<dyn AsyncIo>)
}

View File

@@ -41,9 +41,8 @@ impl DiskFile for RawFileDiskSync {
fn new_async_io(&self, _ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
let mut raw = RawFileSync::new(self.file.as_raw_fd());
raw.alignment = DiskTopology::probe(&self.file)
.map(|t| t.logical_block_size)
.unwrap_or(SECTOR_SIZE);
raw.alignment =
DiskTopology::probe(&self.file).map_or(SECTOR_SIZE, |t| t.logical_block_size);
Ok(Box::new(raw) as Box<dyn AsyncIo>)
}