Skip to content

Commit

Permalink
Fixed a few Clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mibes committed Nov 15, 2023
1 parent 9217d2e commit ab2a765
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions couch_rs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ impl Client {
/// new_with_timeout creates a new Couch client. The URI has to be in this format: http://hostname:5984,
/// The timeout is applied from when the request starts connecting until the response body has finished.
/// Timeout is in seconds.
///
/// # Panics
/// Panics when the AUTHORIZATION header can not be set on the request.
pub fn new_with_timeout(
uri: &str,
username: Option<&str>,
Expand Down
11 changes: 7 additions & 4 deletions couch_rs/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,9 @@ impl Database {
/// Ok(())
/// }
/// ```
///
/// # Panics
/// When the internal json! macro fails to create a json object. Not expected to happen.
pub async fn insert_index(
&self,
name: &str,
Expand Down Expand Up @@ -1215,15 +1218,15 @@ fn get_mandatory_string_value(key: &str, value: &Value) -> CouchResult<String> {

fn to_create_value(doc: &impl TypedCouchDocument) -> CouchResult<serde_json::Map<String, Value>> {
let mut value = get_value_map(doc)?;
set_if_not_empty(ID_FIELD, doc.get_id().to_string(), &mut value);
set_if_not_empty(ID_FIELD, doc.get_id().as_ref(), &mut value);
value.remove(REV_FIELD);
Ok(value)
}

fn to_upsert_value(doc: &impl TypedCouchDocument) -> CouchResult<serde_json::Map<String, Value>> {
let mut value = get_value_map(doc)?;
set_if_not_empty(ID_FIELD, doc.get_id().to_string(), &mut value);
set_if_not_empty(REV_FIELD, doc.get_rev().to_string(), &mut value);
set_if_not_empty(ID_FIELD, doc.get_id().as_ref(), &mut value);
set_if_not_empty(REV_FIELD, doc.get_rev().as_ref(), &mut value);
Ok(value)
}

Expand All @@ -1240,7 +1243,7 @@ fn get_value_map(doc: &impl TypedCouchDocument) -> CouchResult<serde_json::Map<S
Ok(value)
}

fn set_if_not_empty(field_name: &str, field_value: String, value: &mut serde_json::Map<String, Value>) {
fn set_if_not_empty(field_name: &str, field_value: &str, value: &mut serde_json::Map<String, Value>) {
if field_value.is_empty() {
value.remove(field_name);
} else {
Expand Down
2 changes: 1 addition & 1 deletion couch_rs_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ name = "couch_rs_derive"
proc-macro = true

[dependencies]
proc-macro2 = ">1.0.66"
proc-macro2 = "^1.0.66"
quote = "1.0"
syn = { version = "2.0", features = ["visit"] }

0 comments on commit ab2a765

Please sign in to comment.