UnexpectedEof,
}
impl IOError {
- pub(crate) fn from_rust(err: io::Error) -> Self {
- match err.kind() {
+ pub(crate) fn from_rust_kind(err: io::ErrorKind) -> Self {
+ match err {
io::ErrorKind::NotFound => IOError::NotFound,
io::ErrorKind::PermissionDenied => IOError::PermissionDenied,
io::ErrorKind::ConnectionRefused => IOError::ConnectionRefused,
_ => IOError::Other,
}
}
- pub(crate) fn to_rust(&self) -> io::Error {
- io::Error::new(match self {
+ pub(crate) fn from_rust(err: io::Error) -> Self {
+ Self::from_rust_kind(err.kind())
+ }
+ pub(crate) fn to_rust_kind(&self) -> io::ErrorKind {
+ match self {
IOError::NotFound => io::ErrorKind::NotFound,
IOError::PermissionDenied => io::ErrorKind::PermissionDenied,
IOError::ConnectionRefused => io::ErrorKind::ConnectionRefused,
IOError::Interrupted => io::ErrorKind::Interrupted,
IOError::Other => io::ErrorKind::Other,
IOError::UnexpectedEof => io::ErrorKind::UnexpectedEof,
- }, "")
+ }
+ }
+ pub(crate) fn to_rust(&self) -> io::Error {
+ io::Error::new(self.to_rust_kind(), "")
}
}
fn drop(&mut self) {
if self.result_ok {
if unsafe { !self.contents.result.is_null() } {
- unsafe { Box::from_raw(self.contents.result) };
+ let _ = unsafe { Box::from_raw(self.contents.result) };
}
} else if unsafe { !self.contents.err.is_null() } {
- unsafe { Box::from_raw(self.contents.err) };
+ let _ = unsafe { Box::from_raw(self.contents.err) };
}
}
}
impl<T> Drop for SmartPtr<T> {
fn drop(&mut self) {
if self.ptr != core::ptr::null_mut() {
- unsafe { Box::from_raw(self.ptr); }
+ let _ = unsafe { Box::from_raw(self.ptr) };
}
}
}