From f64fb10bc87bb4b5a5291d09364ad6c725a842d8 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Mon, 11 May 2015 19:00:27 -0700 Subject: [PATCH 1/2] feat(header): export __hyper__tm! macro so test modules work with header! --- src/header/common/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/header/common/mod.rs b/src/header/common/mod.rs index 553ba783..feba5909 100644 --- a/src/header/common/mod.rs +++ b/src/header/common/mod.rs @@ -98,7 +98,8 @@ macro_rules! deref( } ); -macro_rules! tm { +#[macro_export] +macro_rules! __hyper__tm { ($id:ident, $tm:ident{$($tf:item)*}) => { #[allow(unused_imports)] mod $tm{ @@ -285,7 +286,7 @@ macro_rules! header { ($id, $n) => ($item)* } - tm! { $id, $tm { $($tf)* }} + __hyper__tm! { $id, $tm { $($tf)* }} }; ($(#[$a:meta])*($id:ident, $n:expr) => ($item:ty)+ $tm:ident{$($tf:item)*}) => { header! { @@ -293,7 +294,7 @@ macro_rules! header { ($id, $n) => ($item)+ } - tm! { $id, $tm { $($tf)* }} + __hyper__tm! { $id, $tm { $($tf)* }} }; ($(#[$a:meta])*($id:ident, $n:expr) => [$item:ty] $tm:ident{$($tf:item)*}) => { header! { @@ -301,7 +302,7 @@ macro_rules! header { ($id, $n) => [$item] } - tm! { $id, $tm { $($tf)* }} + __hyper__tm! { $id, $tm { $($tf)* }} }; ($(#[$a:meta])*($id:ident, $n:expr) => {Any / ($item:ty)+} $tm:ident{$($tf:item)*}) => { header! { @@ -309,7 +310,7 @@ macro_rules! header { ($id, $n) => {Any / ($item)+} } - tm! { $id, $tm { $($tf)* }} + __hyper__tm! { $id, $tm { $($tf)* }} }; } From 62d96adc6b852b3836b47fc2e154bbdbab9ad7f6 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Mon, 11 May 2015 19:00:38 -0700 Subject: [PATCH 2/2] refactor(header): change name of deref! to __hyper__deref! The header is largely for internal use, however, it must be exported because the header! macro uses it. As deref! is also a particularly general name, this renames it to __hyper__deref! to prevent name clashes. BREAKING CHANGE: If you use deref! from the header module, you'll need to switch to using __hyper__deref!. --- src/header/common/cache_control.rs | 2 +- src/header/common/cookie.rs | 2 +- src/header/common/mod.rs | 10 +++++----- src/header/common/set_cookie.rs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/header/common/cache_control.rs b/src/header/common/cache_control.rs index df067ce7..997fdfd7 100644 --- a/src/header/common/cache_control.rs +++ b/src/header/common/cache_control.rs @@ -23,7 +23,7 @@ use header::parsing::{from_one_comma_delimited, fmt_comma_delimited}; #[derive(PartialEq, Clone, Debug)] pub struct CacheControl(pub Vec); -deref!(CacheControl => Vec); +__hyper__deref!(CacheControl => Vec); impl Header for CacheControl { fn header_name() -> &'static str { diff --git a/src/header/common/cookie.rs b/src/header/common/cookie.rs index f9952793..5d279ae3 100644 --- a/src/header/common/cookie.rs +++ b/src/header/common/cookie.rs @@ -20,7 +20,7 @@ use cookie::CookieJar; #[derive(Clone, PartialEq, Debug)] pub struct Cookie(pub Vec); -deref!(Cookie => Vec); +__hyper__deref!(Cookie => Vec); impl Header for Cookie { fn header_name() -> &'static str { diff --git a/src/header/common/mod.rs b/src/header/common/mod.rs index feba5909..55b90597 100644 --- a/src/header/common/mod.rs +++ b/src/header/common/mod.rs @@ -80,7 +80,7 @@ macro_rules! bench_header( ); #[macro_export] -macro_rules! deref( +macro_rules! __hyper__deref { ($from:ty => $to:ty) => { impl ::std::ops::Deref for $from { type Target = $to; @@ -96,7 +96,7 @@ macro_rules! deref( } } } -); +} #[macro_export] macro_rules! __hyper__tm { @@ -166,7 +166,7 @@ macro_rules! header { $(#[$a])* #[derive(Clone, Debug, PartialEq)] pub struct $id(pub Vec<$item>); - deref!($id => Vec<$item>); + __hyper__deref!($id => Vec<$item>); impl $crate::header::Header for $id { fn header_name() -> &'static str { $n @@ -192,7 +192,7 @@ macro_rules! header { $(#[$a])* #[derive(Clone, Debug, PartialEq)] pub struct $id(pub Vec<$item>); - deref!($id => Vec<$item>); + __hyper__deref!($id => Vec<$item>); impl $crate::header::Header for $id { fn header_name() -> &'static str { $n @@ -218,7 +218,7 @@ macro_rules! header { $(#[$a])* #[derive(Clone, Debug, PartialEq)] pub struct $id(pub $value); - deref!($id => $value); + __hyper__deref!($id => $value); impl $crate::header::Header for $id { fn header_name() -> &'static str { $n diff --git a/src/header/common/set_cookie.rs b/src/header/common/set_cookie.rs index 604f1b2a..2b3f3d27 100644 --- a/src/header/common/set_cookie.rs +++ b/src/header/common/set_cookie.rs @@ -57,7 +57,7 @@ use cookie::CookieJar; #[derive(Clone, PartialEq, Debug)] pub struct SetCookie(pub Vec); -deref!(SetCookie => Vec); +__hyper__deref!(SetCookie => Vec); impl Header for SetCookie { fn header_name() -> &'static str {