Skip to content

Commit ead174f

Browse files
xtqqczzecakebaker
authored andcommitted
refactor: rustix::io::Errno for CatError
1 parent e3b4b41 commit ead174f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/uu/cat/src/cat.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ enum CatError {
8484
/// Wrapper around `io::Error`
8585
#[error("{}", strip_errno(.0))]
8686
Io(#[from] io::Error),
87-
/// Wrapper around `rustix::io::Errno`
88-
#[cfg(any(target_os = "linux", target_os = "android"))]
89-
#[error("{0}")]
90-
Rustix(#[from] rustix::io::Errno),
9187
/// Unknown file type; it's not a regular file, socket, etc.
9288
#[error("{}", translate!("cat-error-unknown-filetype", "ft_debug" => .ft_debug))]
9389
UnknownFiletype {
@@ -107,6 +103,13 @@ enum CatError {
107103

108104
type CatResult<T> = Result<T, CatError>;
109105

106+
#[cfg(any(target_os = "linux", target_os = "android"))]
107+
impl From<rustix::io::Errno> for CatError {
108+
fn from(value: rustix::io::Errno) -> Self {
109+
Self::Io(value.into())
110+
}
111+
}
112+
110113
#[derive(PartialEq)]
111114
enum NumberingMode {
112115
None,
@@ -453,7 +456,7 @@ fn get_input_type(path: &OsString) -> CatResult<InputType> {
453456
return Err(CatError::TooManySymlinks);
454457
}
455458
}
456-
return Err(CatError::Io(e));
459+
return Err(e.into());
457460
}
458461
};
459462
match ft {

0 commit comments

Comments
 (0)