From ca035734df2e3dfeb866cbfee51de7b582be83f5 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sat, 8 Dec 2018 13:47:33 -0700 Subject: Replace try! with ? try! is not available in Rust 2018 --- src/fcntl.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/fcntl.rs') diff --git a/src/fcntl.rs b/src/fcntl.rs index 5942506b..a763c10f 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -139,17 +139,17 @@ libc_bitflags!( ); pub fn open(path: &P, oflag: OFlag, mode: Mode) -> Result { - let fd = try!(path.with_nix_path(|cstr| { + let fd = path.with_nix_path(|cstr| { unsafe { libc::open(cstr.as_ptr(), oflag.bits(), mode.bits() as c_uint) } - })); + })?; Errno::result(fd) } pub fn openat(dirfd: RawFd, path: &P, oflag: OFlag, mode: Mode) -> Result { - let fd = try!(path.with_nix_path(|cstr| { + let fd = path.with_nix_path(|cstr| { unsafe { libc::openat(dirfd, cstr.as_ptr(), oflag.bits(), mode.bits() as c_uint) } - })); + })?; Errno::result(fd) } @@ -167,18 +167,18 @@ fn wrap_readlink_result(buffer: &mut[u8], res: ssize_t) -> Result<&OsStr> { } pub fn readlink<'a, P: ?Sized + NixPath>(path: &P, buffer: &'a mut [u8]) -> Result<&'a OsStr> { - let res = try!(path.with_nix_path(|cstr| { + let res = path.with_nix_path(|cstr| { unsafe { libc::readlink(cstr.as_ptr(), buffer.as_mut_ptr() as *mut c_char, buffer.len() as size_t) } - })); + })?; wrap_readlink_result(buffer, res) } pub fn readlinkat<'a, P: ?Sized + NixPath>(dirfd: RawFd, path: &P, buffer: &'a mut [u8]) -> Result<&'a OsStr> { - let res = try!(path.with_nix_path(|cstr| { + let res = path.with_nix_path(|cstr| { unsafe { libc::readlinkat(dirfd, cstr.as_ptr(), buffer.as_mut_ptr() as *mut c_char, buffer.len() as size_t) } - })); + })?; wrap_readlink_result(buffer, res) } -- cgit v1.2.3