Skip to content

Commit

Permalink
typed_insert Header references
Browse files Browse the repository at this point in the history
  • Loading branch information
miraclx committed Jan 25, 2024
1 parent 0f7c1c6 commit 4230cbe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/common/accept_ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use util::FlatCsv;
///
/// let mut headers = HeaderMap::new();
///
/// headers.typed_insert(AcceptRanges::bytes());
/// headers.typed_insert(&AcceptRanges::bytes());
/// ```
#[derive(Clone, Debug, PartialEq)]
pub struct AcceptRanges(FlatCsv);
Expand Down
2 changes: 1 addition & 1 deletion src/common/authorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ mod tests {
fn basic_roundtrip() {
let auth = Authorization::basic("Aladdin", "open sesame");
let mut h = HeaderMap::new();
h.typed_insert(auth.clone());
h.typed_insert(&auth);
assert_eq!(h.typed_get(), Some(auth));
}

Expand Down
4 changes: 2 additions & 2 deletions src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn test_decode<T: ::Header>(values: &[&str]) -> Option<T> {
fn test_encode<T: ::Header>(header: T) -> ::http::HeaderMap {
use HeaderMapExt;
let mut map = ::http::HeaderMap::new();
map.typed_insert(header);
map.typed_insert(&header);
map
}

Expand Down Expand Up @@ -118,7 +118,7 @@ macro_rules! bench_header {
let typed = map.typed_get::<$ty>().unwrap();
b.bytes = $value.len() as u64;
b.iter(|| {
map.typed_insert(typed.clone());
map.typed_insert(&typed);
map.clear();
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/map_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use http;
/// An extension trait adding "typed" methods to `http::HeaderMap`.
pub trait HeaderMapExt: self::sealed::Sealed {
/// Inserts the typed `Header` into this `HeaderMap`.
fn typed_insert<H>(&mut self, header: H)
fn typed_insert<H>(&mut self, header: &H)
where
H: Header;

Expand All @@ -20,7 +20,7 @@ pub trait HeaderMapExt: self::sealed::Sealed {
}

impl HeaderMapExt for http::HeaderMap {
fn typed_insert<H>(&mut self, header: H)
fn typed_insert<H>(&mut self, header: &H)
where
H: Header,
{
Expand Down

0 comments on commit 4230cbe

Please sign in to comment.