Remove redundant calls to Iterator::collect
(#3365)
* Remove redundant calls to `Iterator::collect` * Update mentions.rs * Add clippy lints and run fmt * CI ran on the wrong commit again
This commit is contained in:
parent
e4b739320c
commit
bef76630c5
7 changed files with 14 additions and 15 deletions
|
@ -60,6 +60,9 @@ pipeline:
|
|||
-D clippy::unused_self
|
||||
-A clippy::uninlined_format_args
|
||||
-D clippy::get_first
|
||||
-D clippy::explicit_into_iter_loop
|
||||
-D clippy::explicit_iter_loop
|
||||
-D clippy::needless_collect
|
||||
- cargo clippy --workspace --features console --
|
||||
-D clippy::unwrap_used
|
||||
-D clippy::indexing_slicing
|
||||
|
|
|
@ -98,7 +98,6 @@ pub async fn send_local_notifs(
|
|||
for mention in mentions
|
||||
.iter()
|
||||
.filter(|m| m.is_local(&context.settings().hostname) && m.name.ne(&person.name))
|
||||
.collect::<Vec<&MentionData>>()
|
||||
{
|
||||
let mention_name = mention.name.clone();
|
||||
let user_view = LocalUserView::read_from_name(context.pool(), &mention_name).await;
|
||||
|
|
|
@ -191,7 +191,7 @@ impl PerformCrud for CreateComment {
|
|||
|
||||
pub fn check_comment_depth(comment: &Comment) -> Result<(), LemmyError> {
|
||||
let path = &comment.path.0;
|
||||
let length = path.split('.').collect::<Vec<&str>>().len();
|
||||
let length = path.split('.').count();
|
||||
if length > MAX_COMMENT_DEPTH_LIMIT {
|
||||
Err(LemmyError::from_message("max_comment_depth_reached"))
|
||||
} else {
|
||||
|
|
|
@ -43,12 +43,11 @@ pub(crate) async fn send_activity_in_community(
|
|||
|
||||
// send to user followers
|
||||
if !is_mod_action {
|
||||
inboxes.append(
|
||||
inboxes.extend(
|
||||
&mut PersonFollower::list_followers(context.pool(), actor.id)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|p| ApubPerson(p).shared_inbox_or_inbox())
|
||||
.collect(),
|
||||
.map(|p| ApubPerson(p).shared_inbox_or_inbox()),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,7 @@ use lemmy_db_schema::{
|
|||
traits::Crud,
|
||||
utils::DbPool,
|
||||
};
|
||||
use lemmy_utils::{
|
||||
error::LemmyError,
|
||||
utils::mention::{scrape_text_for_mentions, MentionData},
|
||||
};
|
||||
use lemmy_utils::{error::LemmyError, utils::mention::scrape_text_for_mentions};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use url::Url;
|
||||
|
@ -67,10 +64,9 @@ pub async fn collect_non_local_mentions(
|
|||
let mentions = scrape_text_for_mentions(&comment.content)
|
||||
.into_iter()
|
||||
// Filter only the non-local ones
|
||||
.filter(|m| !m.is_local(&context.settings().hostname))
|
||||
.collect::<Vec<MentionData>>();
|
||||
.filter(|m| !m.is_local(&context.settings().hostname));
|
||||
|
||||
for mention in &mentions {
|
||||
for mention in mentions {
|
||||
let identifier = format!("{}@{}", mention.name, mention.domain);
|
||||
let person = webfinger_resolve_actor::<LemmyContext, ApubPerson>(&identifier, context).await;
|
||||
if let Ok(person) = person {
|
||||
|
|
|
@ -99,8 +99,7 @@ impl Comment {
|
|||
// left join comment c2 on c2.path <@ c.path and c2.path != c.path
|
||||
// group by c.id
|
||||
|
||||
let path_split = parent_path.0.split('.').collect::<Vec<&str>>();
|
||||
let parent_id = path_split.get(1);
|
||||
let parent_id = parent_path.0.split('.').nth(1);
|
||||
|
||||
if let Some(parent_id) = parent_id {
|
||||
let top_parent = format!("0.{}", parent_id);
|
||||
|
|
|
@ -14,7 +14,10 @@ cargo clippy --workspace --fix --allow-staged --allow-dirty --tests --all-target
|
|||
-D clippy::manual_string_new -D clippy::redundant_closure_for_method_calls \
|
||||
-D clippy::unused_self \
|
||||
-A clippy::uninlined_format_args \
|
||||
-D clippy::get_first
|
||||
-D clippy::get_first \
|
||||
-D clippy::explicit_into_iter_loop \
|
||||
-D clippy::explicit_iter_loop \
|
||||
-D clippy::needless_collect
|
||||
|
||||
cargo clippy --workspace --features console -- \
|
||||
-D clippy::unwrap_used \
|
||||
|
|
Loading…
Reference in a new issue