Use ? instead of try

This commit is contained in:
Michael Doronin
2020-10-28 15:45:49 +03:00
parent ed3d9e32de
commit 554acf08b5
2 changed files with 18 additions and 18 deletions

View File

@@ -27,9 +27,9 @@ use result::*;
/// try! get smbc function or return io::Error(EINVAL)
macro_rules! try_ufn {
($e:ident <- $s:expr) => (try!(unsafe {
($e:ident <- $s:expr) => (unsafe {
$e($s.ctx).ok_or($crate::std::io::Error::from_raw_os_error(libc::EINVAL as i32))
}))
}?)
}
#[inline(always)]
@@ -49,7 +49,7 @@ pub unsafe fn cstr<'a, T>(p: *const T) -> Cow<'a, str> {
}
pub fn cstring<P: AsRef<str>>(p: P) -> Result<CString> {
Ok(try!(CString::new(p.as_ref())))
Ok(CString::new(p.as_ref())?)
}
pub unsafe fn write_to_cstr(dest: *mut u8, len: usize, src: &str) {