summaryrefslogtreecommitdiff
path: root/src/fcntl.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/fcntl.rs
parent5a3ac8df3fa2de86477d961d8b5720b1d283b2d5 (diff)
downloadnix-ca035734df2e3dfeb866cbfee51de7b582be83f5.zip
Replace try! with ?
try! is not available in Rust 2018
Diffstat (limited to 'src/fcntl.rs')
-rw-r--r--src/fcntl.rs16
1 files changed, 8 insertions, 8 deletions
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<P: ?Sized + NixPath>(path: &P, oflag: OFlag, mode: Mode) -> Result<RawFd> {
- 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<P: ?Sized + NixPath>(dirfd: RawFd, path: &P, oflag: OFlag, mode: Mode) -> Result<RawFd> {
- 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)
}