1
Fork 0

Fix clippy::len_zero warnings

This commit is contained in:
Mateusz Mikuła 2019-07-18 14:22:22 +02:00 committed by Mateusz Mikuła
parent f93032c818
commit 124f6ef7cd
4 changed files with 8 additions and 8 deletions

View file

@ -200,7 +200,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
}
}
if self.len() == 0 {
if self.is_empty() {
// Ideally we'd call `BTreeMap::new` here, but that has the `K:
// Ord` constraint, which this method lacks.
BTreeMap {
@ -759,12 +759,12 @@ impl<K: Ord, V> BTreeMap<K, V> {
#[stable(feature = "btree_append", since = "1.11.0")]
pub fn append(&mut self, other: &mut Self) {
// Do we have to append anything at all?
if other.len() == 0 {
if other.is_empty() {
return;
}
// We can just swap `self` and `other` if `self` is empty.
if self.len() == 0 {
if self.is_empty() {
mem::swap(self, other);
return;
}

View file

@ -46,7 +46,7 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> {
type Item = Utf8LossyChunk<'a>;
fn next(&mut self) -> Option<Utf8LossyChunk<'a>> {
if self.source.len() == 0 {
if self.source.is_empty() {
return None;
}
@ -141,7 +141,7 @@ impl fmt::Display for Utf8Lossy {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// If we're the empty string then our iterator won't actually yield
// anything, so perform the formatting manually
if self.bytes.len() == 0 {
if self.bytes.is_empty() {
return "".fmt(f)
}

View file

@ -1923,7 +1923,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
if !self.done_first {
match self.first.read(buf)? {
0 if buf.len() != 0 => self.done_first = true,
0 if !buf.is_empty() => self.done_first = true,
n => return Ok(n),
}
}
@ -1955,7 +1955,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
fn fill_buf(&mut self) -> Result<&[u8]> {
if !self.done_first {
match self.first.fill_buf()? {
buf if buf.len() == 0 => { self.done_first = true; }
buf if buf.is_empty() => { self.done_first = true; }
buf => return Ok(buf),
}
}

View file

@ -277,7 +277,7 @@ impl Command {
if self.get_gid().is_some() ||
self.get_uid().is_some() ||
self.env_saw_path() ||
self.get_closures().len() != 0 {
!self.get_closures().is_empty() {
return Ok(None)
}