chore: Fix some new clippy warnings
This commit is contained in:
@@ -543,7 +543,7 @@ impl TryFrom<RumaImageMessageEventContent> for ImageMessageContent {
|
||||
fn try_from(value: RumaImageMessageEventContent) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
filename: value.filename().to_owned(),
|
||||
caption: value.caption().map(ToString::to_string),
|
||||
caption: value.caption().map(str::to_owned),
|
||||
formatted_caption: value.formatted_caption().map(Into::into),
|
||||
source: Arc::new(value.source.try_into()?),
|
||||
info: value.info.as_deref().map(TryInto::try_into).transpose()?,
|
||||
@@ -582,7 +582,7 @@ impl TryFrom<RumaAudioMessageEventContent> for AudioMessageContent {
|
||||
fn try_from(value: RumaAudioMessageEventContent) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
filename: value.filename().to_owned(),
|
||||
caption: value.caption().map(ToString::to_string),
|
||||
caption: value.caption().map(str::to_owned),
|
||||
formatted_caption: value.formatted_caption().map(Into::into),
|
||||
source: Arc::new(value.source.try_into()?),
|
||||
info: value.info.as_deref().map(Into::into),
|
||||
@@ -619,7 +619,7 @@ impl TryFrom<RumaVideoMessageEventContent> for VideoMessageContent {
|
||||
fn try_from(value: RumaVideoMessageEventContent) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
filename: value.filename().to_owned(),
|
||||
caption: value.caption().map(ToString::to_string),
|
||||
caption: value.caption().map(str::to_owned),
|
||||
formatted_caption: value.formatted_caption().map(Into::into),
|
||||
source: Arc::new(value.source.try_into()?),
|
||||
info: value.info.as_deref().map(TryInto::try_into).transpose()?,
|
||||
@@ -654,7 +654,7 @@ impl TryFrom<RumaFileMessageEventContent> for FileMessageContent {
|
||||
fn try_from(value: RumaFileMessageEventContent) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
filename: value.filename().to_owned(),
|
||||
caption: value.caption().map(ToString::to_string),
|
||||
caption: value.caption().map(str::to_owned),
|
||||
formatted_caption: value.formatted_caption().map(Into::into),
|
||||
source: Arc::new(value.source.try_into()?),
|
||||
info: value.info.as_deref().map(TryInto::try_into).transpose()?,
|
||||
|
||||
@@ -278,7 +278,7 @@ impl SessionVerificationController {
|
||||
sender_profile,
|
||||
flow_id: request.flow_id().into(),
|
||||
device_id: other_device_data.device_id().into(),
|
||||
device_display_name: other_device_data.display_name().map(str::to_string),
|
||||
device_display_name: other_device_data.display_name().map(str::to_owned),
|
||||
first_seen_timestamp: other_device_data.first_time_seen_ts().into(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
use std::{
|
||||
cmp::Reverse,
|
||||
collections::{BTreeMap, BTreeSet, HashMap},
|
||||
sync::RwLock,
|
||||
};
|
||||
@@ -878,7 +879,7 @@ impl StateStore for MemoryStore {
|
||||
.or_default()
|
||||
.clone();
|
||||
// Inverted order of priority, use stable sort to keep insertion order.
|
||||
ret.sort_by(|lhs, rhs| rhs.priority.cmp(&lhs.priority));
|
||||
ret.sort_by_key(|item| Reverse(item.priority));
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use std::{cmp::Reverse, marker::PhantomData};
|
||||
|
||||
use super::{
|
||||
Chunk, ChunkContent, ChunkIdentifier, ChunkIdentifierGenerator, Ends, LinkedChunk,
|
||||
@@ -287,7 +287,7 @@ where
|
||||
// Sort by `next` so that the search for the next chunk is faster (it should
|
||||
// come first). The chunk with the biggest next chunk identifier comes first.
|
||||
// Chunk with no next chunk comes last.
|
||||
chunks.sort_by(|a, b| b.next.cmp(&a.next));
|
||||
chunks.sort_by_key(|item| Reverse(item.next));
|
||||
|
||||
let last_chunk = chunks
|
||||
.pop()
|
||||
|
||||
@@ -745,8 +745,8 @@ impl GroupSessionManager {
|
||||
// Filter out the devices that already received this room key or have a
|
||||
// to-device message already queued up.
|
||||
let devices: Vec<_> = devices
|
||||
.into_iter()
|
||||
.flat_map(|(_, d)| {
|
||||
.into_values()
|
||||
.flat_map(|d| {
|
||||
d.into_iter().filter(|d| match outbound.sharing_view().get_share_state(d) {
|
||||
ShareState::NotShared => true,
|
||||
ShareState::Shared { message_index: _, olm_wedging_index } => {
|
||||
|
||||
@@ -662,7 +662,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[allow(unknown_lints, clippy::unchecked_duration_subtraction)]
|
||||
#[allow(unknown_lints, clippy::unchecked_time_subtraction)]
|
||||
#[async_test]
|
||||
async fn test_timing_out() {
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
use std::{
|
||||
cmp::Reverse,
|
||||
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
|
||||
str::FromStr as _,
|
||||
sync::Arc,
|
||||
@@ -1703,7 +1704,7 @@ impl_state_store!({
|
||||
)?;
|
||||
|
||||
// Inverted stable ordering on priority.
|
||||
prev.sort_by(|lhs, rhs| rhs.priority.unwrap_or(0).cmp(&lhs.priority.unwrap_or(0)));
|
||||
prev.sort_by_key(|item| Reverse(item.priority.unwrap_or(0)));
|
||||
|
||||
Ok(prev.into_iter().filter_map(PersistedQueuedRequest::into_queued_request).collect())
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ impl LeaveSpaceHandle {
|
||||
}
|
||||
})
|
||||
.map(|p: (ruma::OwnedUserId, i64)| p.0)
|
||||
.chain(privileged_creator_ids.into_iter());
|
||||
.chain(privileged_creator_ids);
|
||||
|
||||
let mut joined_owner_ids = Vec::new();
|
||||
for owner_id in owner_ids {
|
||||
|
||||
@@ -263,6 +263,7 @@ impl Channel {
|
||||
let etag = get_header(headers, &ETAG)?;
|
||||
let expires = get_header(headers, &EXPIRES)?;
|
||||
let last_modified = get_header(headers, &LAST_MODIFIED)?;
|
||||
#[allow(clippy::result_large_err)]
|
||||
let content_type = headers
|
||||
.get(CONTENT_TYPE)
|
||||
.map(|c| c.to_str().map_err(FromHttpResponseError::<RumaApiError>::from))
|
||||
|
||||
@@ -2864,7 +2864,7 @@ fn canonicalize_dependent_requests(
|
||||
}
|
||||
}
|
||||
|
||||
by_txn.into_iter().flat_map(|(_parent_txn_id, entries)| entries.into_iter().cloned()).collect()
|
||||
by_txn.into_values().flat_map(|entries| entries.into_iter().cloned()).collect()
|
||||
}
|
||||
|
||||
#[cfg(all(test, not(target_family = "wasm")))]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use futures_util::StreamExt;
|
||||
|
||||
@@ -167,11 +167,7 @@ impl InvitedRoomView {
|
||||
column,
|
||||
row,
|
||||
..
|
||||
}) => {
|
||||
if self.buttons.click(column, row) {
|
||||
self.join_or_leave()
|
||||
}
|
||||
}
|
||||
}) if self.buttons.click(column, row) => self.join_or_leave(),
|
||||
|
||||
Event::Mouse(MouseEvent { kind: MouseEventKind::Up(MouseButton::Left), .. }) => {
|
||||
self.buttons.release();
|
||||
|
||||
Reference in New Issue
Block a user