Skip to content

Commit 124f6ef

Browse files
committed
Fix clippy::len_zero warnings
1 parent f93032c commit 124f6ef

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/liballoc/collections/btree/map.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
200200
}
201201
}
202202

203-
if self.len() == 0 {
203+
if self.is_empty() {
204204
// Ideally we'd call `BTreeMap::new` here, but that has the `K:
205205
// Ord` constraint, which this method lacks.
206206
BTreeMap {
@@ -759,12 +759,12 @@ impl<K: Ord, V> BTreeMap<K, V> {
759759
#[stable(feature = "btree_append", since = "1.11.0")]
760760
pub fn append(&mut self, other: &mut Self) {
761761
// Do we have to append anything at all?
762-
if other.len() == 0 {
762+
if other.is_empty() {
763763
return;
764764
}
765765

766766
// We can just swap `self` and `other` if `self` is empty.
767-
if self.len() == 0 {
767+
if self.is_empty() {
768768
mem::swap(self, other);
769769
return;
770770
}

src/libcore/str/lossy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> {
4646
type Item = Utf8LossyChunk<'a>;
4747

4848
fn next(&mut self) -> Option<Utf8LossyChunk<'a>> {
49-
if self.source.len() == 0 {
49+
if self.source.is_empty() {
5050
return None;
5151
}
5252

@@ -141,7 +141,7 @@ impl fmt::Display for Utf8Lossy {
141141
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142142
// If we're the empty string then our iterator won't actually yield
143143
// anything, so perform the formatting manually
144-
if self.bytes.len() == 0 {
144+
if self.bytes.is_empty() {
145145
return "".fmt(f)
146146
}
147147

src/libstd/io/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> {
19231923
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
19241924
if !self.done_first {
19251925
match self.first.read(buf)? {
1926-
0 if buf.len() != 0 => self.done_first = true,
1926+
0 if !buf.is_empty() => self.done_first = true,
19271927
n => return Ok(n),
19281928
}
19291929
}
@@ -1955,7 +1955,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
19551955
fn fill_buf(&mut self) -> Result<&[u8]> {
19561956
if !self.done_first {
19571957
match self.first.fill_buf()? {
1958-
buf if buf.len() == 0 => { self.done_first = true; }
1958+
buf if buf.is_empty() => { self.done_first = true; }
19591959
buf => return Ok(buf),
19601960
}
19611961
}

src/libstd/sys/unix/process/process_unix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl Command {
277277
if self.get_gid().is_some() ||
278278
self.get_uid().is_some() ||
279279
self.env_saw_path() ||
280-
self.get_closures().len() != 0 {
280+
!self.get_closures().is_empty() {
281281
return Ok(None)
282282
}
283283

0 commit comments

Comments
 (0)