Skip to content

Commit da88c0a

Browse files
committed
Fix clippy warnings
1 parent a803496 commit da88c0a

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/lib.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818

1919
const TEMPFILE_ATTEMPTS: u32 = 100;
2020

21-
use libc;
22-
use nix;
23-
use openat;
2421
use rand::Rng;
2522
use std::ffi::OsStr;
2623
use std::fs::File;
@@ -140,7 +137,7 @@ pub trait OpenatDirExt {
140137

141138
/// Create a `FileWriter` which provides a `std::io::BufWriter` and then atomically creates
142139
/// the file at the destination, renaming it over an existing one if necessary.
143-
fn new_file_writer<'a>(&'a self, mode: libc::mode_t) -> io::Result<FileWriter>;
140+
fn new_file_writer(&self, mode: libc::mode_t) -> io::Result<FileWriter>;
144141

145142
/// Atomically create or replace the destination file, calling the provided
146143
/// function to generate the contents. Note that the contents of the
@@ -220,7 +217,7 @@ impl OpenatDirExt for openat::Dir {
220217
}
221218

222219
fn remove_file_optional<P: openat::AsPath>(&self, p: P) -> io::Result<bool> {
223-
Ok(impl_remove_file_optional(self, p)?)
220+
impl_remove_file_optional(self, p)
224221
}
225222

226223
fn remove_dir_optional<P: openat::AsPath>(&self, p: P) -> io::Result<bool> {
@@ -414,8 +411,8 @@ impl OpenatDirExt for openat::Dir {
414411
Ok(())
415412
}
416413

417-
fn new_file_writer<'a>(&'a self, mode: libc::mode_t) -> io::Result<FileWriter> {
418-
let (tmpf, name) = if let Some(tmpf) = self.new_unnamed_file(mode).ok() {
414+
fn new_file_writer(&self, mode: libc::mode_t) -> io::Result<FileWriter> {
415+
let (tmpf, name) = if let Ok(tmpf) = self.new_unnamed_file(mode) {
419416
(tmpf, None)
420417
} else {
421418
// FIXME allow this to be configurable
@@ -498,7 +495,7 @@ pub(crate) fn tempfile_in(
498495
match d.new_file(tmpname.as_str(), mode) {
499496
Ok(f) => return Ok((f, tmpname)),
500497
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => continue,
501-
Err(e) => Err(e)?,
498+
Err(e) => return Err(e),
502499
}
503500
}
504501
Err(io::Error::new(
@@ -515,7 +512,7 @@ pub(crate) fn tempfile_in(
515512
/// optimal case where all components exist above.
516513
pub(crate) fn impl_ensure_dir_all(d: &openat::Dir, p: &Path, mode: libc::mode_t) -> io::Result<()> {
517514
if let Some(parent) = p.parent() {
518-
if parent.as_os_str().len() > 0 {
515+
if !parent.as_os_str().is_empty() {
519516
impl_ensure_dir_all(d, parent, mode)?;
520517
}
521518
}
@@ -781,7 +778,7 @@ impl FileExt for File {
781778
fn pread_exact(&self, buf: &mut [u8], start_pos: usize) -> io::Result<()> {
782779
use nix::sys::uio::pread;
783780

784-
if buf.len() == 0 {
781+
if buf.is_empty() {
785782
return Err(io::Error::new(
786783
io::ErrorKind::InvalidInput,
787784
"zero-sized buffer in input",

0 commit comments

Comments
 (0)