diff --git a/src/os/unix/mod.rs b/src/os/unix/mod.rs index e14cdbf..dadbe9d 100644 --- a/src/os/unix/mod.rs +++ b/src/os/unix/mod.rs @@ -118,7 +118,7 @@ impl Library { where P: AsRef { let filename = match filename { None => None, - Some(ref f) => Some(try!(cstr_cow_from_bytes(f.as_ref().as_bytes()))), + Some(ref f) => Some(cstr_cow_from_bytes(f.as_ref().as_bytes())?), }; with_dlerror(move || { let result = unsafe { @@ -149,7 +149,7 @@ impl Library { where F: FnOnce() -> ::Result> { ensure_compatible_types::(); - let symbol = try!(cstr_cow_from_bytes(symbol)); + let symbol = cstr_cow_from_bytes(symbol)?; // `dlsym` may return nullptr in two cases: when a symbol genuinely points to a null // pointer or the symbol cannot be found. In order to detect this case a double dlerror // pattern must be used, which is, sadly, a little bit racy. diff --git a/src/os/windows/mod.rs b/src/os/windows/mod.rs index 6ea272c..6d0126b 100644 --- a/src/os/windows/mod.rs +++ b/src/os/windows/mod.rs @@ -73,7 +73,7 @@ impl Library { /// definied behaviour. pub unsafe fn get(&self, symbol: &[u8]) -> ::Result> { ensure_compatible_types::(); - let symbol = try!(cstr_cow_from_bytes(symbol)); + let symbol = cstr_cow_from_bytes(symbol)?; with_get_last_error(|| { let symbol = libloaderapi::GetProcAddress(self.0, symbol.as_ptr()); if symbol.is_null() { diff --git a/src/util.rs b/src/util.rs index 650266e..5fe8164 100644 --- a/src/util.rs +++ b/src/util.rs @@ -42,9 +42,9 @@ pub fn cstr_cow_from_bytes<'a>(slice: &'a [u8]) -> Result, NullErr // Slice out of 0 elements None => unsafe { Cow::Borrowed(CStr::from_ptr(&ZERO)) }, // Slice with trailing 0 - Some(&0) => Cow::Borrowed(try!(CStr::from_bytes_with_nul(slice))), + Some(&0) => Cow::Borrowed(CStr::from_bytes_with_nul(slice)?), // Slice with no trailing 0 - Some(_) => Cow::Owned(try!(CString::new(slice))), + Some(_) => Cow::Owned(CString::new(slice)?), }) }