11use std:: collections:: HashMap ;
2+ use std:: fmt:: Display ;
23
34use html2md:: common:: get_tag_attr;
45use html2md:: { parse_html_custom, TagHandler , TagHandlerFactory } ;
@@ -62,8 +63,8 @@ pub struct Problem {
6263 pub sample_test_case : String ,
6364}
6465
65- impl ToString for DailyChallenge {
66- fn to_string ( & self ) -> String {
66+ impl Display for DailyChallenge {
67+ fn fmt ( & self , f : & mut std :: fmt :: Formatter < ' _ > ) -> std :: fmt :: Result {
6768 console_debug ! ( "Raw html content: {}" , self . question. content) ;
6869 let mut custom_parser: HashMap < String , Box < dyn TagHandlerFactory > > = HashMap :: new ( ) ;
6970 custom_parser
@@ -93,7 +94,7 @@ impl ToString for DailyChallenge {
9394 . map ( |c| format ! ( "```rs\n struct Solution;\n \n {}\n ```" , c. code) )
9495 . unwrap_or_default ( ) ;
9596
96- format ! (
97+ f . write_fmt ( format_args ! (
9798 r#"{parsed}
9899
99100> Enlace:
@@ -105,16 +106,16 @@ impl ToString for DailyChallenge {
105106{code}
106107"# ,
107108 self . link
108- )
109+ ) )
109110 }
110111}
111112
112- impl ToString for ProblemDifficulty {
113- fn to_string ( & self ) -> String {
113+ impl Display for ProblemDifficulty {
114+ fn fmt ( & self , f : & mut std :: fmt :: Formatter < ' _ > ) -> std :: fmt :: Result {
114115 match self {
115- ProblemDifficulty :: Easy => "facil" . to_owned ( ) ,
116- ProblemDifficulty :: Medium => "intermedio" . to_owned ( ) ,
117- ProblemDifficulty :: Hard => "dificil" . to_owned ( ) ,
116+ ProblemDifficulty :: Easy => f . write_str ( "facil" ) ,
117+ ProblemDifficulty :: Medium => f . write_str ( "intermedio" ) ,
118+ ProblemDifficulty :: Hard => f . write_str ( "dificil" ) ,
118119 }
119120 }
120121}
0 commit comments