Skip to content

Commit 30f982a

Browse files
committed
Replace &HeaderName with Into<HeaderName>
1 parent db616d5 commit 30f982a

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

src/headers/headers.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Headers {
6464
values: impl ToHeaderValues,
6565
) -> crate::Result<()> {
6666
let name = name.into();
67-
match self.get_mut(&name) {
67+
match self.get_mut(name.clone()) {
6868
Some(headers) => {
6969
let mut values: HeaderValues = values.to_header_values()?.collect();
7070
headers.append(&mut values);
@@ -82,13 +82,13 @@ impl Headers {
8282
}
8383

8484
/// Get a mutable reference to a header.
85-
pub fn get_mut(&mut self, name: &HeaderName) -> Option<&mut HeaderValues> {
86-
self.headers.get_mut(name)
85+
pub fn get_mut(&mut self, name: impl Into<HeaderName>) -> Option<&mut HeaderValues> {
86+
self.headers.get_mut(&name.into())
8787
}
8888

8989
/// Remove a header.
90-
pub fn remove(&mut self, name: &HeaderName) -> Option<HeaderValues> {
91-
self.headers.remove(name)
90+
pub fn remove(&mut self, name: impl Into<HeaderName>) -> Option<HeaderValues> {
91+
self.headers.remove(&name.into())
9292
}
9393

9494
/// An iterator visiting all header pairs in arbitrary order.

src/request.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,13 @@ impl Request {
369369
}
370370

371371
/// Get a mutable reference to a header.
372-
pub fn header_mut(&mut self, name: &HeaderName) -> Option<&mut HeaderValues> {
373-
self.headers.get_mut(name)
372+
pub fn header_mut(&mut self, name: impl Into<HeaderName>) -> Option<&mut HeaderValues> {
373+
self.headers.get_mut(name.into())
374374
}
375375

376376
/// Remove a header.
377-
pub fn remove_header(&mut self, name: &HeaderName) -> Option<HeaderValues> {
378-
self.headers.remove(name)
377+
pub fn remove_header(&mut self, name: impl Into<HeaderName>) -> Option<HeaderValues> {
378+
self.headers.remove(name.into())
379379
}
380380

381381
/// Set an HTTP header.

src/response.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ impl Response {
6969
}
7070

7171
/// Get a mutable reference to a header.
72-
pub fn header_mut(&mut self, name: &HeaderName) -> Option<&mut HeaderValues> {
73-
self.headers.get_mut(name)
72+
pub fn header_mut(&mut self, name: impl Into<HeaderName>) -> Option<&mut HeaderValues> {
73+
self.headers.get_mut(name.into())
7474
}
7575

7676
/// Get an HTTP header.
7777
pub fn header(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues> {
78-
self.headers.get(name)
78+
self.headers.get(name.into())
7979
}
8080

8181
/// Remove a header.
82-
pub fn remove_header(&mut self, name: &HeaderName) -> Option<HeaderValues> {
83-
self.headers.remove(name)
82+
pub fn remove_header(&mut self, name: impl Into<HeaderName>) -> Option<HeaderValues> {
83+
self.headers.remove(name.into())
8484
}
8585

8686
/// Set an HTTP header.

src/security/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub fn powered_by(mut headers: impl AsMut<Headers>, value: Option<HeaderValue>)
105105
headers.as_mut().insert(name, value);
106106
}
107107
None => {
108-
headers.as_mut().remove(&name);
108+
headers.as_mut().remove(name);
109109
}
110110
};
111111
}

src/trailers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,17 @@ impl Trailers {
121121
}
122122

123123
/// Get a reference to a header.
124-
pub fn get(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues> {
124+
pub fn get(&self, name: &impl Into<HeaderName>) -> Option<&HeaderValues> {
125125
self.headers.get(name)
126126
}
127127

128128
/// Get a mutable reference to a header.
129-
pub fn get_mut(&mut self, name: &HeaderName) -> Option<&mut HeaderValues> {
129+
pub fn get_mut(&mut self, name: impl Into<HeaderName>) -> Option<&mut HeaderValues> {
130130
self.headers.get_mut(name)
131131
}
132132

133133
/// Remove a header.
134-
pub fn remove(&mut self, name: &HeaderName) -> Option<HeaderValues> {
134+
pub fn remove(&mut self, name: impl Into<HeaderName>) -> Option<HeaderValues> {
135135
self.headers.remove(name)
136136
}
137137

0 commit comments

Comments
 (0)