@@ -4,33 +4,25 @@ use anyhow::Result;
44
55pub struct PRSummaryGenerator ;
66
7- #[ derive( Debug , Clone ) ]
7+ #[ derive( Debug , Clone , Default ) ]
88pub struct SummaryOptions {
99 pub include_diagram : bool ,
1010}
1111
12- impl Default for SummaryOptions {
13- fn default ( ) -> Self {
14- Self {
15- include_diagram : false ,
16- }
17- }
18- }
19-
2012impl PRSummaryGenerator {
2113 #[ allow( dead_code) ]
2214 pub async fn generate_summary (
2315 diffs : & [ UnifiedDiff ] ,
2416 git : & GitIntegration ,
25- adapter : & Box < dyn LLMAdapter > ,
17+ adapter : & dyn LLMAdapter ,
2618 ) -> Result < PRSummary > {
2719 Self :: generate_summary_with_options ( diffs, git, adapter, SummaryOptions :: default ( ) ) . await
2820 }
2921
3022 pub async fn generate_summary_with_options (
3123 diffs : & [ UnifiedDiff ] ,
3224 git : & GitIntegration ,
33- adapter : & Box < dyn LLMAdapter > ,
25+ adapter : & dyn LLMAdapter ,
3426 options : SummaryOptions ,
3527 ) -> Result < PRSummary > {
3628 // Get commit messages for context
@@ -57,7 +49,7 @@ impl PRSummaryGenerator {
5749
5850 pub async fn generate_change_diagram (
5951 diffs : & [ UnifiedDiff ] ,
60- adapter : & Box < dyn LLMAdapter > ,
52+ adapter : & dyn LLMAdapter ,
6153 ) -> Result < Option < String > > {
6254 let stats = Self :: calculate_stats ( diffs) ;
6355 let prompt = Self :: build_diagram_prompt ( diffs, & stats) ;
@@ -133,7 +125,7 @@ impl PRSummaryGenerator {
133125 prompt. push_str ( "Generate a comprehensive PR summary based on the following changes:\n \n " ) ;
134126
135127 // Add statistics
136- prompt. push_str ( & format ! ( "## Statistics\n " ) ) ;
128+ prompt. push_str ( "## Statistics\n " ) ;
137129 prompt. push_str ( & format ! ( "- Files changed: {}\n " , stats. files_changed) ) ;
138130 prompt. push_str ( & format ! ( "- Lines added: {}\n " , stats. lines_added) ) ;
139131 prompt. push_str ( & format ! ( "- Lines removed: {}\n " , stats. lines_removed) ) ;
@@ -147,7 +139,7 @@ impl PRSummaryGenerator {
147139 for commit in commits. iter ( ) . take ( 5 ) {
148140 prompt. push_str ( & format ! ( "- {}\n " , commit) ) ;
149141 }
150- prompt. push_str ( " \n " ) ;
142+ prompt. push ( '\n' ) ;
151143 }
152144
153145 // Add file changes summary
@@ -376,7 +368,7 @@ impl PRSummary {
376368 for change in & self . key_changes {
377369 output. push_str ( & format ! ( "- {}\n " , change) ) ;
378370 }
379- output. push_str ( " \n " ) ;
371+ output. push ( '\n' ) ;
380372 }
381373
382374 // Statistics
@@ -406,7 +398,7 @@ impl PRSummary {
406398 self . stats. doc_files
407399 ) ) ;
408400 }
409- output. push_str ( " \n " ) ;
401+ output. push ( '\n' ) ;
410402
411403 // Breaking changes
412404 if let Some ( breaking) = & self . breaking_changes {
@@ -444,15 +436,15 @@ fn extract_mermaid_diagram(content: &str) -> Option<String> {
444436 }
445437
446438 // Seek to mermaid block
447- while let Some ( next_line) = lines. next ( ) {
439+ for next_line in lines. by_ref ( ) {
448440 let next_trimmed = next_line. trim ( ) ;
449441 if next_trimmed. starts_with ( "```" ) && next_trimmed. contains ( "mermaid" ) {
450442 break ;
451443 }
452444 }
453445
454446 let mut diagram_lines = Vec :: new ( ) ;
455- while let Some ( block_line) = lines. next ( ) {
447+ for block_line in lines. by_ref ( ) {
456448 let block_trimmed = block_line. trim ( ) ;
457449 if block_trimmed. starts_with ( "```" ) {
458450 break ;
0 commit comments