diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-02-29 02:16:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-29 02:16:21 +0100 |
| commit | c8db7dcc1cd91366dda9bea92e38b5d215ede1f1 (patch) | |
| tree | 30b13312973df647f11481151c9fc7bea077479a /src/libcore/slice/mod.rs | |
| parent | ba2df27525ab535aa600cd25fda4aa7f0f13a2aa (diff) | |
| parent | 1622b6ef7372c40381914facf8794d851fcd9eb1 (diff) | |
| download | rust-c8db7dcc1cd91366dda9bea92e38b5d215ede1f1.tar.gz rust-c8db7dcc1cd91366dda9bea92e38b5d215ede1f1.zip | |
Rollup merge of #69551 - matthiaskrgr:len_zero, r=Mark-Simulacrum
use is_empty() instead of len() == x to determine if structs are empty.
Diffstat (limited to 'src/libcore/slice/mod.rs')
| -rw-r--r-- | src/libcore/slice/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 7c65f595790..9a4561f2869 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -3823,7 +3823,7 @@ where // The last index of self.v is already checked and found to match // by the last iteration, so we start searching a new match // one index to the left. - let remainder = if self.v.len() == 0 { &[] } else { &self.v[..(self.v.len() - 1)] }; + let remainder = if self.v.is_empty() { &[] } else { &self.v[..(self.v.len() - 1)] }; let idx = remainder.iter().rposition(|x| (self.pred)(x)).map(|idx| idx + 1).unwrap_or(0); if idx == 0 { self.finished = true; @@ -4033,7 +4033,7 @@ where return None; } - let idx_opt = if self.v.len() == 0 { + let idx_opt = if self.v.is_empty() { None } else { // work around borrowck limitations |
