summaryrefslogtreecommitdiff
path: root/src/sys/stat.rs
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2018-12-08 13:47:33 -0700
committerAlan Somers <asomers@gmail.com>2018-12-08 13:51:43 -0700
commitca035734df2e3dfeb866cbfee51de7b582be83f5 (patch)
treedbbf94ee5189b13ea4d448ba63512b43f85b4ba8 /src/sys/stat.rs
parent5a3ac8df3fa2de86477d961d8b5720b1d283b2d5 (diff)
downloadnix-ca035734df2e3dfeb866cbfee51de7b582be83f5.zip
Replace try! with ?
try! is not available in Rust 2018
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)
}