chore: Fix new clippy warnings

This commit is contained in:
Kévin Commaille 2024-07-29 15:00:21 +02:00 committed by Kévin Commaille
parent 6087f7efbb
commit 04654f8833
5 changed files with 16 additions and 20 deletions

View File

@ -188,13 +188,13 @@ mod tests {
#[test]
fn serialize_string() {
assert_eq!(to_json_value(&Action::Notify).unwrap(), json!("notify"));
assert_eq!(to_json_value(Action::Notify).unwrap(), json!("notify"));
}
#[test]
fn serialize_tweak_sound() {
assert_eq!(
to_json_value(&Action::SetTweak(Tweak::Sound("default".into()))).unwrap(),
to_json_value(Action::SetTweak(Tweak::Sound("default".into()))).unwrap(),
json!({ "set_tweak": "sound", "value": "default" })
);
}
@ -202,12 +202,12 @@ mod tests {
#[test]
fn serialize_tweak_highlight() {
assert_eq!(
to_json_value(&Action::SetTweak(Tweak::Highlight(true))).unwrap(),
to_json_value(Action::SetTweak(Tweak::Highlight(true))).unwrap(),
json!({ "set_tweak": "highlight" })
);
assert_eq!(
to_json_value(&Action::SetTweak(Tweak::Highlight(false))).unwrap(),
to_json_value(Action::SetTweak(Tweak::Highlight(false))).unwrap(),
json!({ "set_tweak": "highlight", "value": false })
);
}

View File

@ -364,7 +364,7 @@ impl StrExt for str {
return false;
}
let has_wildcards = pattern.contains(|c| matches!(c, '?' | '*'));
let has_wildcards = pattern.contains(['?', '*']);
if has_wildcards {
let mut chunks: Vec<String> = vec![];

View File

@ -36,13 +36,13 @@ fn serialize_redacted_message_event_content() {
#[test]
fn serialize_empty_redacted_aliases_event_content() {
assert_eq!(to_json_value(&RedactedRoomAliasesEventContent::default()).unwrap(), json!({}));
assert_eq!(to_json_value(RedactedRoomAliasesEventContent::default()).unwrap(), json!({}));
}
#[test]
fn redacted_aliases_event_serialize_with_content() {
let expected = json!({ "aliases": [] });
let actual = to_json_value(&RedactedRoomAliasesEventContent::new_v1(vec![])).unwrap();
let actual = to_json_value(RedactedRoomAliasesEventContent::new_v1(vec![])).unwrap();
assert_eq!(actual, expected);
}

View File

@ -342,11 +342,7 @@ pub mod v1 {
// If a highlight tweak is given with no value, its value is defined to be
// true.
"highlight" => {
let highlight = if let Ok(highlight) = access.next_value() {
highlight
} else {
true
};
let highlight = access.next_value().unwrap_or(true);
tweaks.push(Tweak::Highlight(highlight));
}

View File

@ -40,7 +40,7 @@ static REFERENCE_HASH_FIELDS_TO_REMOVE: &[&str] = &["signatures", "unsigned"];
/// # Parameters
///
/// * entity_id: The identifier of the entity creating the signature. Generally this means a
/// homeserver, e.g. "example.com".
/// homeserver, e.g. "example.com".
/// * key_pair: A cryptographic key pair used to sign the JSON.
/// * object: A JSON object to sign according and append a signature to.
///
@ -167,9 +167,9 @@ pub fn canonical_json(object: &CanonicalJsonObject) -> Result<String, Error> {
/// # Parameters
///
/// * public_key_map: A map from entity identifiers to a map from key identifiers to public keys.
/// Generally, entity identifiers are server names — the host/IP/port of a homeserver (e.g.
/// "example.com") for which a signature must be verified. Key identifiers for each server (e.g.
/// "ed25519:1") then map to their respective public keys.
/// Generally, entity identifiers are server names — the host/IP/port of a homeserver (e.g.
/// "example.com") for which a signature must be verified. Key identifiers for each server (e.g.
/// "ed25519:1") then map to their respective public keys.
/// * object: The JSON object that was signed.
///
/// # Errors
@ -355,7 +355,7 @@ pub fn reference_hash(
/// # Parameters
///
/// * entity_id: The identifier of the entity creating the signature. Generally this means a
/// homeserver, e.g. "example.com".
/// homeserver, e.g. "example.com".
/// * key_pair: A cryptographic key pair used to sign the event.
/// * object: A JSON object to be hashed and signed according to the Matrix specification.
///
@ -486,9 +486,9 @@ where
/// # Parameters
///
/// * public_key_map: A map from entity identifiers to a map from key identifiers to public keys.
/// Generally, entity identifiers are server names—the host/IP/port of a homeserver (e.g.
/// "example.com") for which a signature must be verified. Key identifiers for each server (e.g.
/// "ed25519:1") then map to their respective public keys.
/// Generally, entity identifiers are server names—the host/IP/port of a homeserver (e.g.
/// "example.com") for which a signature must be verified. Key identifiers for each server (e.g.
/// "ed25519:1") then map to their respective public keys.
/// * object: The JSON object of the event that was signed.
/// * version: Room version of the given event
///