[fractal] fractal-matrix-api: Remove length comparisons to zero
- From: Alexandre Franke <afranke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] fractal-matrix-api: Remove length comparisons to zero
- Date: Sun, 23 Dec 2018 11:07:09 +0000 (UTC)
commit 01068ad7521c10d1b7c17b0554d22c330804add9
Author: Zeeshan Ali <zeenix collabora co uk>
Date: Wed Dec 12 23:05:44 2018 +0100
fractal-matrix-api: Remove length comparisons to zero
This fixes some errors from clippy about needless length comparison to 0:
```
error: length comparison to zero
--> fractal-matrix-api/src/util.rs:483:27
|
483 | if array.is_none() || array.unwrap().len() == 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more
explicit: `array.unwrap().is_empty()`
|
= note: `-D clippy::len-zero` implied by `-D warnings`
= help: for further information visit
https://rust-lang-nursery.github.io/rust-clippy/master/index.html#len_zero
```
Related: #370
fractal-matrix-api/src/backend/room.rs | 2 +-
fractal-matrix-api/src/util.rs | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/fractal-matrix-api/src/backend/room.rs b/fractal-matrix-api/src/backend/room.rs
index 6e9d5c1..09f8898 100644
--- a/fractal-matrix-api/src/backend/room.rs
+++ b/fractal-matrix-api/src/backend/room.rs
@@ -206,7 +206,7 @@ fn parse_context(
ms.push(m);
}
- if ms.len() == 0 && id.is_some() {
+ if ms.is_empty() && id.is_some() {
// there's no messages so we'll try with a bigger context
if let Err(err) =
parse_context(tx.clone(), tk, baseu, roomid, &id.unwrap(), limit * 2)
diff --git a/fractal-matrix-api/src/util.rs b/fractal-matrix-api/src/util.rs
index f8f616d..7ccfaa5 100644
--- a/fractal-matrix-api/src/util.rs
+++ b/fractal-matrix-api/src/util.rs
@@ -471,7 +471,7 @@ pub fn get_room_media_list(
let r = json_q("get", &url, &json!(null), globals::TIMEOUT)?;
let array = r["chunk"].as_array();
let prev_batch = r["end"].to_string().trim_matches('"').to_string();
- if array.is_none() || array.unwrap().len() == 0 {
+ if array.is_none() || array.unwrap().is_empty() {
return Ok((vec![], prev_batch));
}
@@ -814,7 +814,7 @@ pub fn fill_room_gap(
nend = String::from(r["end"].as_str().unwrap_or(""));
let array = r["chunk"].as_array();
- if array.is_none() || array.unwrap().len() == 0 {
+ if array.is_none() || array.unwrap().is_empty() {
return Ok(ms);
}
@@ -836,7 +836,7 @@ pub fn build_url(base: &Url, path: &str, params: &[(&str, String)]) -> Result<Ur
{
// If len was 0 `?` would be appended without being needed.
- if params.len() >= 1 {
+ if !params.is_empty() {
let mut query = url.query_pairs_mut();
query.clear();
for (k, v) in params {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]