We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
as
TryFrom
1 parent 40e873d commit 148255cCopy full SHA for 148255c
src/error.rs
@@ -77,18 +77,16 @@ impl Error {
77
/// [1]: https://doc.rust-lang.org/std/io/struct.Error.html#method.raw_os_error
78
#[inline]
79
pub fn raw_os_error(self) -> Option<i32> {
80
- if self.0.get() < Self::INTERNAL_START {
81
- match () {
82
- #[cfg(target_os = "solid_asp3")]
+ const _: () = assert!(i32::MAX.unsigned_abs() == Error::INTERNAL_START - 1);
+ i32::try_from(self.0.get()).ok().map(|errno| {
+ if cfg!(target_os = "solid_asp3") {
83
// On SOLID, negate the error code again to obtain the original
84
// error code.
85
- () => Some(-(self.0.get() as i32)),
86
- #[cfg(not(target_os = "solid_asp3"))]
87
- () => Some(self.0.get() as i32),
+ -errno
+ } else {
+ errno
88
}
89
- } else {
90
- None
91
- }
+ })
92
93
94
/// Extract the bare error code.
0 commit comments