Skip to content

Commit 9871d55

Browse files
committed
remove unsafe
1 parent 1e2a5aa commit 9871d55

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/error.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ impl fmt::Display for Error {
4343
impl From<io::Error> for Error {
4444
fn from(err: io::Error) -> Self {
4545
err.raw_os_error()
46-
.map(|code| Error(unsafe {
47-
// all supported targets use 0 as success code
48-
NonZeroU32::new_unchecked(code as u32)
49-
}))
46+
.and_then(|code| NonZeroU32::new(code as u32))
47+
.map(|code| Error(code))
5048
// in practice this should never happen
5149
.unwrap_or(UNKNOWN_ERROR)
5250
}

0 commit comments

Comments
 (0)