Apply clippy suggestions

This commit is contained in:
timvisee 2018-05-17 02:09:52 +02:00
parent f0ca016f4a
commit b62f3fd343
No known key found for this signature in database
GPG key ID: 109CBA0BF74036C2
34 changed files with 126 additions and 119 deletions

View file

@ -94,7 +94,7 @@ impl EncryptedFileReader {
/// returned.
fn read_internal(&mut self, buf: &mut [u8]) -> usize {
// Return if there is no data to read
if self.internal_buf.is_empty() || buf.len() == 0 {
if self.internal_buf.is_empty() || buf.is_empty() {
return 0;
}
@ -335,6 +335,11 @@ pub trait ProgressReporter: Send {
pub trait ExactLengthReader {
/// Get the exact length of the reader in bytes.
fn len(&self) -> Result<u64, io::Error>;
/// Check whehter this extact length reader is emtpy.
fn is_empty(&self) -> Result<bool, io::Error> {
self.len().map(|l| l == 0)
}
}
impl<R: ExactLengthReader + Read> ExactLengthReader for BufReader<R> {