Skip to content

Commit 8eec683

Browse files
jplattepoljar
authored andcommitted
refactor: Use inline format arguments more
Automated with cargo clippy --fix --workspace --all-targets.
1 parent 4705389 commit 8eec683

File tree

21 files changed

+40
-61
lines changed

21 files changed

+40
-61
lines changed

benchmarks/benches/room_bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn receive_all_members_benchmark(c: &mut Criterion) {
2929
let f = EventFactory::new().room(&room_id);
3030
let mut member_events: Vec<Raw<RoomMemberEvent>> = Vec::with_capacity(MEMBERS_IN_ROOM);
3131
for i in 0..MEMBERS_IN_ROOM {
32-
let user_id = OwnedUserId::try_from(format!("@user_{}:matrix.org", i)).unwrap();
32+
let user_id = OwnedUserId::try_from(format!("@user_{i}:matrix.org")).unwrap();
3333
let event = f
3434
.member(&user_id)
3535
.membership(MembershipState::Join)

bindings/matrix-sdk-ffi/src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,7 +2338,7 @@ impl TryFrom<RumaJoinRule> for JoinRule {
23382338
}
23392339
RumaJoinRule::Invite => Ok(JoinRule::Invite),
23402340
RumaJoinRule::_Custom(_) => Ok(JoinRule::Custom { repr: value.as_str().to_owned() }),
2341-
_ => Err(format!("Unknown JoinRule: {:?}", value)),
2341+
_ => Err(format!("Unknown JoinRule: {value:?}")),
23422342
}
23432343
}
23442344
}
@@ -2355,7 +2355,7 @@ impl TryFrom<RumaAllowRule> for AllowRule {
23552355
.map_err(|e| format!("Couldn't serialize custom AllowRule: {e:?}"))?;
23562356
Ok(Self::Custom { json })
23572357
}
2358-
_ => Err(format!("Invalid AllowRule: {:?}", value)),
2358+
_ => Err(format!("Invalid AllowRule: {value:?}")),
23592359
}
23602360
}
23612361
}

bindings/matrix-sdk-ffi/src/notification_settings.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl TryFrom<SdkTweak> for Tweak {
290290
SdkTweak::Highlight(highlight) => Self::Highlight { value: highlight },
291291
SdkTweak::Custom { name, value } => {
292292
let json_string = serde_json::to_string(&value)
293-
.map_err(|e| format!("Failed to serialize custom tweak value: {}", e))?;
293+
.map_err(|e| format!("Failed to serialize custom tweak value: {e}"))?;
294294

295295
Self::Custom { name, value: json_string }
296296
}
@@ -308,9 +308,9 @@ impl TryFrom<Tweak> for SdkTweak {
308308
Tweak::Highlight { value } => Self::Highlight(value),
309309
Tweak::Custom { name, value } => {
310310
let json_value: serde_json::Value = serde_json::from_str(&value)
311-
.map_err(|e| format!("Failed to deserialize custom tweak value: {}", e))?;
311+
.map_err(|e| format!("Failed to deserialize custom tweak value: {e}"))?;
312312
let value = serde_json::from_value(json_value)
313-
.map_err(|e| format!("Failed to convert JSON value: {}", e))?;
313+
.map_err(|e| format!("Failed to convert JSON value: {e}"))?;
314314

315315
Self::Custom { name, value }
316316
}
@@ -334,7 +334,7 @@ impl TryFrom<SdkAction> for Action {
334334
Ok(match value {
335335
SdkAction::Notify => Self::Notify,
336336
SdkAction::SetTweak(tweak) => Self::SetTweak {
337-
value: tweak.try_into().map_err(|e| format!("Failed to convert tweak: {}", e))?,
337+
value: tweak.try_into().map_err(|e| format!("Failed to convert tweak: {e}"))?,
338338
},
339339
_ => return Err("Unsupported action type".to_owned()),
340340
})
@@ -348,7 +348,7 @@ impl TryFrom<Action> for SdkAction {
348348
Ok(match value {
349349
Action::Notify => Self::Notify,
350350
Action::SetTweak { value } => Self::SetTweak(
351-
value.try_into().map_err(|e| format!("Failed to convert tweak: {}", e))?,
351+
value.try_into().map_err(|e| format!("Failed to convert tweak: {e}"))?,
352352
),
353353
})
354354
}

bindings/matrix-sdk-ffi/src/ruma.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ impl From<&RumaMatrixId> for MatrixId {
182182
event_id: event_id.to_string(),
183183
}
184184
} else {
185-
panic!("Unexpected MatrixId type: {:?}", room_id_or_alias)
185+
panic!("Unexpected MatrixId type: {room_id_or_alias:?}")
186186
}
187187
}
188-
_ => panic!("Unexpected MatrixId type: {:?}", value),
188+
_ => panic!("Unexpected MatrixId type: {value:?}"),
189189
}
190190
}
191191
}

bindings/matrix-sdk-ffi/src/widget.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,7 @@ mod tests {
647647
let cap_assert = |capability: &str| {
648648
assert!(
649649
permission_array.contains(&capability.to_owned()),
650-
"The \"{}\" capability was missing from the element call capability list.",
651-
capability
650+
"The \"{capability}\" capability was missing from the element call capability list."
652651
);
653652
};
654653

crates/matrix-sdk-base/src/room/display_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn compute_display_name_from_heroes(
472472
heroes.sort_unstable();
473473

474474
let names = if num_heroes == 0 && num_joined_invited > 1 {
475-
format!("{} people", num_joined_invited)
475+
format!("{num_joined_invited} people")
476476
} else if num_heroes >= num_joined_invited_except_self {
477477
heroes.join(", ")
478478
} else if num_heroes < num_joined_invited_except_self && num_joined_invited > 1 {

crates/matrix-sdk-base/src/room/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl From<&MembershipState> for RoomState {
4949
MembershipState::Join => Self::Joined,
5050
MembershipState::Knock => Self::Knocked,
5151
MembershipState::Leave => Self::Left,
52-
_ => panic!("Unexpected MembershipState: {}", membership_state),
52+
_ => panic!("Unexpected MembershipState: {membership_state}"),
5353
}
5454
}
5555
}

crates/matrix-sdk-sqlite/src/crypto_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ mod tests {
17391739
let olm_sessions =
17401740
database.get_sessions(id).await.expect("Should have some olm sessions");
17411741

1742-
println!("### Session id: {:?}", id);
1742+
println!("### Session id: {id:?}");
17431743
assert_eq!(olm_sessions.map_or(0, |v| v.len()), count);
17441744
}
17451745

crates/matrix-sdk-sqlite/src/event_cache_store.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,8 +1111,7 @@ impl EventCacheStore for SqliteEventCacheStore {
11111111
};
11121112

11131113
let query = format!(
1114-
"SELECT content FROM events WHERE relates_to = ? AND room_id = ? {}",
1115-
filter_query
1114+
"SELECT content FROM events WHERE relates_to = ? AND room_id = ? {filter_query}"
11161115
);
11171116

11181117
// Collect related events.

crates/matrix-sdk-ui/src/timeline/tests/edit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async fn test_live_sanitized() {
8787
let new_html_content = "<edited/> <strong>better</strong> message";
8888
timeline
8989
.handle_live_event(
90-
f.text_html(format!("* {}", new_plain_content), format!("* {}", new_html_content))
90+
f.text_html(format!("* {new_plain_content}"), format!("* {new_html_content}"))
9191
.sender(&ALICE)
9292
.edit(
9393
first_event_id,

0 commit comments

Comments
 (0)