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/sys/stat.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/sys/stat.rs') diff --git a/src/sys/stat.rs b/src/sys/stat.rs index f3a2e7e3..e0367859 100644 --- a/src/sys/stat.rs +++ b/src/sys/stat.rs @@ -43,11 +43,11 @@ libc_bitflags! { } pub fn mknod(path: &P, kind: SFlag, perm: Mode, dev: dev_t) -> Result<()> { - let res = try!(path.with_nix_path(|cstr| { + let res = path.with_nix_path(|cstr| { unsafe { libc::mknod(cstr.as_ptr(), kind.bits | perm.bits() as mode_t, dev) } - })); + })?; Errno::result(res).map(drop) } @@ -79,26 +79,26 @@ pub fn umask(mode: Mode) -> Mode { pub fn stat(path: &P) -> Result { let mut dst = unsafe { mem::uninitialized() }; - let res = try!(path.with_nix_path(|cstr| { + let res = path.with_nix_path(|cstr| { unsafe { libc::stat(cstr.as_ptr(), &mut dst as *mut FileStat) } - })); + })?; - try!(Errno::result(res)); + Errno::result(res)?; Ok(dst) } pub fn lstat(path: &P) -> Result { let mut dst = unsafe { mem::uninitialized() }; - let res = try!(path.with_nix_path(|cstr| { + let res = path.with_nix_path(|cstr| { unsafe { libc::lstat(cstr.as_ptr(), &mut dst as *mut FileStat) } - })); + })?; - try!(Errno::result(res)); + Errno::result(res)?; Ok(dst) } @@ -107,18 +107,18 @@ pub fn fstat(fd: RawFd) -> Result { let mut dst = unsafe { mem::uninitialized() }; let res = unsafe { libc::fstat(fd, &mut dst as *mut FileStat) }; - try!(Errno::result(res)); + Errno::result(res)?; Ok(dst) } pub fn fstatat(dirfd: RawFd, pathname: &P, f: AtFlags) -> Result { let mut dst = unsafe { mem::uninitialized() }; - let res = try!(pathname.with_nix_path(|cstr| { + let res = pathname.with_nix_path(|cstr| { unsafe { libc::fstatat(dirfd, cstr.as_ptr(), &mut dst as *mut FileStat, f.bits() as libc::c_int) } - })); + })?; - try!(Errno::result(res)); + Errno::result(res)?; Ok(dst) } -- cgit v1.2.3