@@ -14,6 +14,11 @@ use crate::{
1414} ; 
1515use  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. 
1722pub  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    } 
0 commit comments