diff options
Diffstat (limited to 'src/errno.rs')
-rw-r--r-- | src/errno.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/errno.rs b/src/errno.rs index 5b0d61f8..df149f5b 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -64,11 +64,21 @@ impl Errno { clear() } + pub(crate) fn result2<S: ErrnoSentinel + PartialEq<S>>(value: S) + -> std::result::Result<S, Self> + { + if value == S::sentinel() { + Err(Self::last()) + } else { + Ok(value) + } + } + /// Returns `Ok(value)` if it does not contain the sentinel value. This /// should not be used when `-1` is not the errno sentinel value. pub fn result<S: ErrnoSentinel + PartialEq<S>>(value: S) -> Result<S> { if value == S::sentinel() { - Err(Error::Sys(Self::last())) + Err(Error::from(Self::last())) } else { Ok(value) } |