fix: replace Error::new(ErrorKind::Other) with Error::other() for clippy compliance

This commit is contained in:
overtrue
2025-06-10 22:15:52 +08:00
parent 6afb26b377
commit 4252377249
+18 -27
View File
@@ -18,30 +18,24 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
let reserved = match bfree.checked_sub(bavail) { let reserved = match bfree.checked_sub(bavail) {
Some(reserved) => reserved, Some(reserved) => reserved,
None => { None => {
return Err(Error::new( return Err(Error::other(format!(
ErrorKind::Other, "detected f_bavail space ({}) > f_bfree space ({}), fs corruption at ({}). please run 'fsck'",
format!( bavail,
"detected f_bavail space ({}) > f_bfree space ({}), fs corruption at ({}). please run 'fsck'", bfree,
bavail, p.as_ref().display()
bfree, )));
p.as_ref().display()
),
));
} }
}; };
let total = match blocks.checked_sub(reserved) { let total = match blocks.checked_sub(reserved) {
Some(total) => total * bsize, Some(total) => total * bsize,
None => { None => {
return Err(Error::new( return Err(Error::other(format!(
ErrorKind::Other, "detected reserved space ({}) > blocks space ({}), fs corruption at ({}). please run 'fsck'",
format!( reserved,
"detected reserved space ({}) > blocks space ({}), fs corruption at ({}). please run 'fsck'", blocks,
reserved, p.as_ref().display()
blocks, )));
p.as_ref().display()
),
));
} }
}; };
@@ -49,15 +43,12 @@ pub fn get_info(p: impl AsRef<Path>) -> std::io::Result<DiskInfo> {
let used = match total.checked_sub(free) { let used = match total.checked_sub(free) {
Some(used) => used, Some(used) => used,
None => { None => {
return Err(Error::new( return Err(Error::other(format!(
ErrorKind::Other, "detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'",
format!( free,
"detected free space ({}) > total drive space ({}), fs corruption at ({}). please run 'fsck'", total,
free, p.as_ref().display()
total, )));
p.as_ref().display()
),
));
} }
}; };