From 0dde0b9c530e2c6f1b8c3acfb63b962d61a5eed8 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Sat, 1 Jun 2024 18:17:57 -0700 Subject: [PATCH] clippy --- kordophone/src/api/http_client.rs | 25 +++++++++---------------- kordophone/src/model/conversation.rs | 2 +- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/kordophone/src/api/http_client.rs b/kordophone/src/api/http_client.rs index fd554f6..96b5c91 100644 --- a/kordophone/src/api/http_client.rs +++ b/kordophone/src/api/http_client.rs @@ -1,22 +1,15 @@ extern crate hyper; extern crate serde; -use std::{path::PathBuf, str::FromStr, str}; -use log::{info, warn, error, trace}; +use std::{path::PathBuf, str}; +use log::{error}; -use hyper::{Body, Client, Method, Request, Uri, body}; - -use tower_hyper::client::Client as TowerClient; -use tower_http::{ - trace::TraceLayer, - classify::StatusInRangeAsFailures, -}; -use tower::{ServiceBuilder, Service}; +use hyper::{Body, Client, Method, Request, Uri}; +use tower::{ServiceBuilder}; use async_trait::async_trait; use serde::de::DeserializeOwned; -use serde_json::Error as SerdeError; -use serde_plain::{Deserializer, derive_deserialize_from_fromstr}; + use crate::{APIInterface, model::Conversation}; type HttpClient = Client; @@ -63,12 +56,12 @@ impl APIInterface for HTTPClient { impl HTTPClient { pub fn new(base_url: Uri) -> HTTPClient { - let mut client = ServiceBuilder::new() + let client = ServiceBuilder::new() .service(Client::new()); HTTPClient { - base_url: base_url, - client: client, + base_url, + client, } } @@ -167,6 +160,6 @@ mod test { let client = local_mock_client(); let conversations = client.get_conversations().await.unwrap(); - assert!(conversations.len() > 0); + assert!(!conversations.is_empty()); } } diff --git a/kordophone/src/model/conversation.rs b/kordophone/src/model/conversation.rs index fdca656..96d2f0d 100644 --- a/kordophone/src/model/conversation.rs +++ b/kordophone/src/model/conversation.rs @@ -79,7 +79,7 @@ impl ConversationBuilder { date: self.date.unwrap_or(OffsetDateTime::now_utc()), unread_count: self.unread_count.unwrap_or(0), last_message_preview: self.last_message_preview, - participant_display_names: self.participant_display_names.unwrap_or(vec![]), + participant_display_names: self.participant_display_names.unwrap_or_default(), display_name: self.display_name, } }