Skip to content

Commit 171e399

Browse files
committed
Implement clippy suggestions
1 parent c565d05 commit 171e399

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/handlers/expand_threads_link.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ pub async fn handle_expand_threads_link(
7979
}
8080

8181
fn build_threads_embed_from_html(parsed_html: &scraper::Html) -> Result<Embed, anyhow::Error> {
82-
let threads_title = meta_tag_content(&parsed_html, "property", "og:title").unwrap_or_default();
83-
let threads_url = meta_tag_content(&parsed_html, "property", "og:url").unwrap_or_default();
82+
let threads_title = meta_tag_content(parsed_html, "property", "og:title").unwrap_or_default();
83+
let threads_url = meta_tag_content(parsed_html, "property", "og:url").unwrap_or_default();
8484
let threads_description =
85-
meta_tag_content(&parsed_html, "property", "og:description").unwrap_or_default();
86-
let threads_image = meta_tag_content(&parsed_html, "property", "og:image").unwrap_or_default();
85+
meta_tag_content(parsed_html, "property", "og:description").unwrap_or_default();
86+
let threads_image = meta_tag_content(parsed_html, "property", "og:image").unwrap_or_default();
8787
let threads_image_type =
88-
meta_tag_content(&parsed_html, "name", "twitter:card").unwrap_or_default();
88+
meta_tag_content(parsed_html, "name", "twitter:card").unwrap_or_default();
8989
let image_is_profile_avatar = threads_image_type == "summary";
9090

9191
let embed_builder = EmbedBuilder::new()
@@ -113,12 +113,11 @@ fn parse_threads_links(interaction: &InteractionCreate) -> Vec<Url> {
113113

114114
let links_iterator = resolved_command_data
115115
.messages
116-
.iter()
117-
.map(|(_, m)| m)
116+
.values()
118117
.map(|m| &m.content)
119118
.flat_map(|content| {
120119
finder
121-
.links(&content)
120+
.links(content)
122121
.filter(|l| l.kind() == &LinkKind::Url)
123122
.filter_map(|l| Url::parse(l.as_str()).ok())
124123
.filter(|l| {

src/handlers/fix_twitter_link.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,16 @@ fn message_content_from_interaction(interaction: &InteractionCreate) -> Option<&
8484
};
8585

8686
match command_data.kind {
87-
CommandType::ChatInput => command_data
88-
.options
89-
.iter()
90-
.next()
91-
.map(|opt| &opt.value)
92-
.and_then(|value| match value {
93-
CommandOptionValue::String(value) => Some(value.as_str()),
94-
_ => None,
95-
}),
87+
CommandType::ChatInput => {
88+
command_data
89+
.options
90+
.first()
91+
.map(|opt| &opt.value)
92+
.and_then(|value| match value {
93+
CommandOptionValue::String(value) => Some(value.as_str()),
94+
_ => None,
95+
})
96+
}
9697
CommandType::Message => command_data
9798
.resolved
9899
.as_ref()
@@ -145,7 +146,7 @@ fn fix_twitter_links_in_place(
145146
"mobile.x.com" => "fixupx.com",
146147
_ => "fxtwitter.com",
147148
};
148-
if let Err(_) = parsed_url.set_host(Some(new_host)) {
149+
if parsed_url.set_host(Some(new_host)).is_err() {
149150
continue;
150151
}
151152

0 commit comments

Comments
 (0)