Skip to content

Commit

Permalink
refactor(headers): Use fold method
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Wong committed Jan 4, 2025
1 parent 4037f42 commit bed38a5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/http/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ impl FromIterator<String> for Headers {

impl Display for Headers {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(
&self
.0
.iter()
.map(|(key, value)| format!("{key}: {value}{CRLF}"))
.collect::<String>(),
)
f.write_str(&self.0.iter().fold(String::new(), |acc, (key, value)| {
acc + &format!("{key}: {value}{CRLF}")
}))
}
}

0 comments on commit bed38a5

Please sign in to comment.