summaryrefslogtreecommitdiff
path: root/src/sys/stat.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-09 01:05:23 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-09 01:05:23 +0000
commitf1b12d6b1b8bf6d8ad41e7b2967b95c6f876745c (patch)
treedbbf94ee5189b13ea4d448ba63512b43f85b4ba8 /src/sys/stat.rs
parent5a3ac8df3fa2de86477d961d8b5720b1d283b2d5 (diff)
parentca035734df2e3dfeb866cbfee51de7b582be83f5 (diff)
downloadnix-f1b12d6b1b8bf6d8ad41e7b2967b95c6f876745c.zip
Merge #995
995: Replace try! with ? r=asomers a=asomers try! is not available in Rust 2018. It would be premature to convert the entire project to Rust 2018, since that would bump the minimum compiler to 1.31.0. But his change will help us when we do convert it eventually. Co-authored-by: Alan Somers <asomers@gmail.com>
Diffstat (limited to 'src/sys/stat.rs')
-rw-r--r--src/sys/stat.rs24
1 files changed, 12 insertions, 12 deletions
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<P: ?Sized + NixPath>(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<P: ?Sized + NixPath>(path: &P) -> Result<FileStat> {
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<P: ?Sized + NixPath>(path: &P) -> Result<FileStat> {
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<FileStat> {
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<P: ?Sized + NixPath>(dirfd: RawFd, pathname: &P, f: AtFlags) -> Result<FileStat> {
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)
}