fix(header): deprecate HeaderFormatter
This commit is contained in:
@@ -10,6 +10,7 @@ license = "MIT"
|
|||||||
authors = ["Sean McArthur <sean.monstar@gmail.com>"]
|
authors = ["Sean McArthur <sean.monstar@gmail.com>"]
|
||||||
keywords = ["http", "hyper", "hyperium"]
|
keywords = ["http", "hyper", "hyperium"]
|
||||||
categories = ["web-programming::http-client", "web-programming::http-server"]
|
categories = ["web-programming::http-client", "web-programming::http-server"]
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = "0.3.0"
|
base64 = "0.3.0"
|
||||||
@@ -32,6 +33,9 @@ num_cpus = "1.0"
|
|||||||
pretty_env_logger = "0.1"
|
pretty_env_logger = "0.1"
|
||||||
spmc = "0.2"
|
spmc = "0.2"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
rustc_version = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
nightly = []
|
nightly = []
|
||||||
|
|||||||
7
build.rs
Normal file
7
build.rs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
extern crate rustc_version as rustc;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
if rustc::version_matches(">= 1.9") {
|
||||||
|
println!("cargo:rustc-cfg=has_deprecated");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -598,6 +598,8 @@ impl<'a> FromIterator<HeaderView<'a>> for Headers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecated! {
|
||||||
|
#[deprecated(note="The semantics of formatting a HeaderFormat directly are not clear")]
|
||||||
impl<'a> fmt::Display for &'a (Header + Send + Sync) {
|
impl<'a> fmt::Display for &'a (Header + Send + Sync) {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
@@ -605,7 +607,10 @@ impl<'a> fmt::Display for &'a (Header + Send + Sync) {
|
|||||||
self.fmt_multi_header(&mut multi)
|
self.fmt_multi_header(&mut multi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deprecated! {
|
||||||
|
#[deprecated(note="The semantics of formatting a HeaderFormat directly are not clear")]
|
||||||
/// A wrapper around any Header with a Display impl that calls `fmt_header`.
|
/// A wrapper around any Header with a Display impl that calls `fmt_header`.
|
||||||
///
|
///
|
||||||
/// This can be used like so: `format!("{}", HeaderFormatter(&header))` to
|
/// This can be used like so: `format!("{}", HeaderFormatter(&header))` to
|
||||||
@@ -614,7 +619,9 @@ impl<'a> fmt::Display for &'a (Header + Send + Sync) {
|
|||||||
/// Note: This may not necessarily be the value written to stream, such
|
/// Note: This may not necessarily be the value written to stream, such
|
||||||
/// as with the SetCookie header.
|
/// as with the SetCookie header.
|
||||||
pub struct HeaderFormatter<'a, H: Header>(pub &'a H);
|
pub struct HeaderFormatter<'a, H: Header>(pub &'a H);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl<'a, H: Header> fmt::Display for HeaderFormatter<'a, H> {
|
impl<'a, H: Header> fmt::Display for HeaderFormatter<'a, H> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
@@ -623,6 +630,7 @@ impl<'a, H: Header> fmt::Display for HeaderFormatter<'a, H> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl<'a, H: Header> fmt::Debug for HeaderFormatter<'a, H> {
|
impl<'a, H: Header> fmt::Debug for HeaderFormatter<'a, H> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
|||||||
@@ -55,6 +55,13 @@ macro_rules! unimplemented {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! deprecated {
|
||||||
|
(#[$note:meta] $i:item) => (
|
||||||
|
#[cfg_attr(has_deprecated, $note)]
|
||||||
|
$i
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod mock;
|
mod mock;
|
||||||
pub mod client;
|
pub mod client;
|
||||||
|
|||||||
Reference in New Issue
Block a user