Skip to content

Commit ec7d038

Browse files
authored
Merge pull request #83 from Juanperias/main
refactor: clippy errors
2 parents ead1554 + c14494b commit ec7d038

30 files changed

+86
-44
lines changed

src/components/blog_content.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ pub fn BlogContent(
117117
}
118118

119119
#[component]
120+
#[must_use]
121+
#[allow(clippy::needless_pass_by_value, clippy::implicit_hasher)]
120122
pub fn ArticleHeader(
121123
#[prop()] title: String,
122124
#[prop()] github_user: Option<String>,
@@ -183,14 +185,14 @@ pub fn ArticleHeader(
183185
})
184186
.collect::<Vec<_>>()}
185187
<div class="flex flex-row flex-wrap items-center gap-2">
186-
{if !social.is_empty() {
188+
{if social.is_empty() {
189+
view! { <></> }
190+
} else {
187191
view! {
188192
<>
189193
<hr class="h-[0.875rem] w-px bg-gray-700 border-0" />
190194
</>
191195
}
192-
} else {
193-
view! { <></> }
194196
}}
195197
{social
196198
.iter()

src/components/button_link.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ use leptos::{component, view, Children, IntoView};
22
use std::collections::HashMap;
33

44
#[component]
5+
#[must_use]
56
pub fn ButtonLink(
67
href: &'static str,
78
#[prop(default = "primary")] color: &'static str,
89
#[prop(default = "normal")] size: &'static str,
910
#[prop(default = "drop")] shadow: &'static str,
10-
#[prop(into, optional)] class: String,
11+
#[prop(into, optional)] class: &'static str,
1112
children: Children,
1213
) -> impl IntoView {
1314
let colors = HashMap::from([

src/components/card_article.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::{
44
};
55
use leptos::{component, view, CollectView, IntoView};
66

7+
#[must_use]
78
#[component]
89
pub fn CardArticle(article: Article, is_home: bool) -> impl IntoView {
910
let article_link = get_link(&article, is_home);
@@ -67,6 +68,7 @@ fn get_description(article: &Article) -> String {
6768
}
6869
}
6970

71+
#[must_use]
7072
#[component]
7173
pub fn TagsList(tags: Option<Vec<String>>) -> impl IntoView {
7274
let tags = tags.unwrap_or_default();
@@ -79,6 +81,8 @@ pub fn TagsList(tags: Option<Vec<String>>) -> impl IntoView {
7981
}
8082

8183
#[component]
84+
#[allow(clippy::needless_pass_by_value)]
85+
#[must_use]
8286
pub fn TagButton(tag: String) -> impl IntoView {
8387
let tag = tag.to_lowercase().replace(' ', "-");
8488

src/components/esta_semana_en_rust/blog_content.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn BlogContent(#[prop()] article: Article) -> impl IntoView {
4242
</h1>
4343
<div class="flex flex-col">
4444
<div class="flex flex-row gap-4 text-sm items-center">
45-
{if !article.has_author() {
45+
{if article.has_author() {
4646
view! {
4747
<>
4848
<h5>{article.author}</h5>
@@ -51,14 +51,14 @@ pub fn BlogContent(#[prop()] article: Article) -> impl IntoView {
5151
} else {
5252
view! { <></> }
5353
}}
54-
{if !social.is_empty() {
54+
{if social.is_empty() {
55+
view! { <></> }
56+
} else {
5557
view! {
5658
<>
5759
<hr class="h-[0.875rem] w-px bg-gray-700 border-0" />
5860
</>
5961
}
60-
} else {
61-
view! { <></> }
6262
}}
6363
<div class="flex flex-row gap-2 items-center">
6464
{social

src/components/esta_semana_en_rust/header.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use leptos::{component, create_signal, view, IntoView, SignalGet, SignalUpdate};
22

33
use crate::components::button_link::ButtonLink;
44

5+
#[must_use]
56
#[component]
67
pub fn Header() -> impl IntoView {
78
let (is_open, set_is_open) = create_signal(false);

src/components/esta_semana_en_rust/layout.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ fn get_year() -> i32 {
1010
chrono::Utc::now().year()
1111
}
1212

13-
#[component]
1413
// This is a common Layout component that will be used by all pages.
14+
#[component]
15+
#[must_use]
1516
pub fn Layout(
1617
#[prop(into, default=format!("Blog de Rust Lang en Español {}", get_year()))] title: String,
1718
#[prop(into, default="Somos una comunidad de Rust hispana, buscamos la promoción del lenguaje de programación Rust.".to_string())]

src/components/feature_articles.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ use crate::{
1414
};
1515
use leptos_mdx::mdx::Mdx;
1616

17+
/// # Panics
18+
/// If no article is found with the tag "esta semana en rust", the call to `unwrap()` will panic.
19+
/// If no article is found with the tag "anuncio de la comunidad", the second `unwrap()` will panic.
20+
/// If the "video" attribute is missing in any `YouTube` component, the `unwrap()` inside the closure will panic.
21+
/// If the value of the "video" attribute is None, the second `unwrap()` will also panic.
1722
pub async fn featured_articles() -> impl IntoView {
1823
let articles = ARTICLES.read().await.clone();
1924
let _invalid_tags = [
@@ -24,15 +29,13 @@ pub async fn featured_articles() -> impl IntoView {
2429
let esta_semana_en_rust = articles
2530
.clone()
2631
.into_iter()
27-
.filter(|article| filter_article_by_tag(article.clone(), "esta semana en rust".to_string()))
32+
.filter(|article| filter_article_by_tag(article, "esta semana en rust"))
2833
.take(1)
2934
.collect::<Vec<Article>>();
3035
let esta_semana_en_rust = esta_semana_en_rust.first().unwrap().to_owned();
3136
let anuncio_de_la_comunidad = articles
3237
.into_iter()
33-
.filter(|article| {
34-
filter_article_by_tag(article.clone(), "anuncio de la comunidad".to_string())
35-
})
38+
.filter(|article| filter_article_by_tag(article, "anuncio de la comunidad"))
3639
.take(1)
3740
.collect::<Vec<Article>>();
3841

@@ -64,9 +67,9 @@ pub async fn featured_articles() -> impl IntoView {
6467
}
6568

6669
#[must_use]
67-
pub fn filter_article_by_tag(article: Article, tag: String) -> bool {
70+
pub fn filter_article_by_tag(article: &Article, tag: &str) -> bool {
6871
if let Some(tags) = &article.tags {
69-
tags.contains(&tag)
72+
tags.contains(&tag.to_string())
7073
} else {
7174
false
7275
}

src/components/header.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::components::button_link::ButtonLink;
44
use crate::components::icons::logo_rust_page::LogoRustPageIcon;
55

66
#[component]
7+
#[must_use]
78
pub fn Header() -> impl IntoView {
89
let (is_open, set_is_open) = create_signal(false);
910

src/components/icons/comments.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use leptos::*;
1+
use leptos::{component, view, IntoView};
22

33
#[component]
4+
#[must_use]
45
pub fn CommentIcon(
56
#[prop(default = 40)] size: u32,
67
#[prop(into, default = "fill-black".to_string())] class: String,

src/components/icons/github.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use leptos::{component, view, IntoView};
22

33
#[component]
4+
#[must_use]
45
pub fn GithubIcon(
56
#[prop(default = 40)] size: u32,
67
#[prop(into, default = "fill-black".to_string())] class: String,

0 commit comments

Comments
 (0)