Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: permit reference types for typed_insert #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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