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] #[test]
fn serialize_string() { fn serialize_string() {
assert_eq!(to_json_value(&Action::Notify).unwrap(), json!("notify")); assert_eq!(to_json_value(Action::Notify).unwrap(), json!("notify"));
} }
#[test] #[test]
fn serialize_tweak_sound() { fn serialize_tweak_sound() {
assert_eq!( 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" }) json!({ "set_tweak": "sound", "value": "default" })
); );
} }
@ -202,12 +202,12 @@ mod tests {
#[test] #[test]
fn serialize_tweak_highlight() { fn serialize_tweak_highlight() {
assert_eq!( assert_eq!(
to_json_value(&Action::SetTweak(Tweak::Highlight(true))).unwrap(), to_json_value(Action::SetTweak(Tweak::Highlight(true))).unwrap(),
json!({ "set_tweak": "highlight" }) json!({ "set_tweak": "highlight" })
); );
assert_eq!( 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 }) json!({ "set_tweak": "highlight", "value": false })
); );
} }

View File

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

View File

@ -36,13 +36,13 @@ fn serialize_redacted_message_event_content() {
#[test] #[test]
fn serialize_empty_redacted_aliases_event_content() { 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] #[test]
fn redacted_aliases_event_serialize_with_content() { fn redacted_aliases_event_serialize_with_content() {
let expected = json!({ "aliases": [] }); 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); 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 // If a highlight tweak is given with no value, its value is defined to be
// true. // true.
"highlight" => { "highlight" => {
let highlight = if let Ok(highlight) = access.next_value() { let highlight = access.next_value().unwrap_or(true);
highlight
} else {
true
};
tweaks.push(Tweak::Highlight(highlight)); tweaks.push(Tweak::Highlight(highlight));
} }