Skip to content

Commit 2c9b996

Browse files
tottotoseanmonstar
authored andcommitted
chore: update to 2018 edition
1 parent 05d9aeb commit 2c9b996

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+295
-212
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ repository = "https://github.com/hyperium/headers"
99
authors = ["Sean McArthur <sean@seanmonstar.com>"]
1010
keywords = ["http", "headers", "hyper", "hyperium"]
1111
categories = ["web-programming"]
12+
edition = "2018"
1213
rust-version = "1.56"
1314

1415
[workspace]

src/common/accept_ranges.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use util::FlatCsv;
1+
use http::HeaderValue;
2+
3+
use crate::util::FlatCsv;
24

35
/// `Accept-Ranges` header, defined in [RFC7233](http://tools.ietf.org/html/rfc7233#section-2.3)
46
///
@@ -39,7 +41,7 @@ const ACCEPT_RANGES_BYTES: &str = "bytes";
3941
impl AcceptRanges {
4042
/// A constructor to easily create the common `Accept-Ranges: bytes` header.
4143
pub fn bytes() -> Self {
42-
AcceptRanges(::HeaderValue::from_static(ACCEPT_RANGES_BYTES).into())
44+
AcceptRanges(HeaderValue::from_static(ACCEPT_RANGES_BYTES).into())
4345
}
4446

4547
/// Check if the unit is `bytes`.
@@ -60,7 +62,7 @@ mod tests {
6062

6163
#[test]
6264
fn bytes_fails() {
63-
let none_range = AcceptRanges(::HeaderValue::from_static("none").into());
65+
let none_range = AcceptRanges(HeaderValue::from_static("none").into());
6466
assert!(!none_range.is_bytes());
6567
}
6668
}

src/common/access_control_allow_credentials.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use {Header, HeaderName, HeaderValue};
1+
use http::{HeaderName, HeaderValue};
2+
3+
use crate::{Error, Header};
24

35
/// `Access-Control-Allow-Credentials` header, part of
46
/// [CORS](http://www.w3.org/TR/cors/#access-control-allow-headers-response-header)
@@ -38,7 +40,7 @@ impl Header for AccessControlAllowCredentials {
3840
&::http::header::ACCESS_CONTROL_ALLOW_CREDENTIALS
3941
}
4042

41-
fn decode<'i, I: Iterator<Item = &'i HeaderValue>>(values: &mut I) -> Result<Self, ::Error> {
43+
fn decode<'i, I: Iterator<Item = &'i HeaderValue>>(values: &mut I) -> Result<Self, Error> {
4244
values
4345
.next()
4446
.and_then(|value| {
@@ -48,10 +50,10 @@ impl Header for AccessControlAllowCredentials {
4850
None
4951
}
5052
})
51-
.ok_or_else(::Error::invalid)
53+
.ok_or_else(Error::invalid)
5254
}
5355

54-
fn encode<E: Extend<::HeaderValue>>(&self, values: &mut E) {
56+
fn encode<E: Extend<HeaderValue>>(&self, values: &mut E) {
5557
values.extend(::std::iter::once(HeaderValue::from_static("true")));
5658
}
5759
}

src/common/access_control_allow_headers.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use std::iter::FromIterator;
22

3-
use util::FlatCsv;
4-
use {HeaderName, HeaderValue};
3+
use http::{HeaderName, HeaderValue};
4+
5+
use crate::util::FlatCsv;
56

67
/// `Access-Control-Allow-Headers` header, part of
78
/// [CORS](http://www.w3.org/TR/cors/#access-control-allow-headers-response-header)

src/common/access_control_allow_methods.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::iter::FromIterator;
22

3-
use http::Method;
3+
use http::{HeaderValue, Method};
44

5-
use util::FlatCsv;
5+
use crate::util::FlatCsv;
66

77
/// `Access-Control-Allow-Methods` header, part of
88
/// [CORS](http://www.w3.org/TR/cors/#access-control-allow-methods-response-header)
@@ -57,7 +57,7 @@ impl FromIterator<Method> for AccessControlAllowMethods {
5757
.map(|method| {
5858
method
5959
.as_str()
60-
.parse::<::HeaderValue>()
60+
.parse::<HeaderValue>()
6161
.expect("Method is a valid HeaderValue")
6262
})
6363
.collect();

src/common/access_control_allow_origin.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use std::convert::TryFrom;
22

3+
use http::HeaderValue;
4+
35
use super::origin::Origin;
4-
use util::{IterExt, TryFromValues};
5-
use HeaderValue;
6+
use crate::util::{IterExt, TryFromValues};
7+
use crate::Error;
68

79
/// The `Access-Control-Allow-Origin` response header,
810
/// part of [CORS](http://www.w3.org/TR/cors/#access-control-allow-origin-response-header)
@@ -65,27 +67,27 @@ impl AccessControlAllowOrigin {
6567
}
6668

6769
impl TryFrom<&str> for AccessControlAllowOrigin {
68-
type Error = ::Error;
70+
type Error = Error;
6971

70-
fn try_from(s: &str) -> Result<Self, ::Error> {
71-
let header_value = HeaderValue::from_str(s).map_err(|_| ::Error::invalid())?;
72+
fn try_from(s: &str) -> Result<Self, Error> {
73+
let header_value = HeaderValue::from_str(s).map_err(|_| Error::invalid())?;
7274
let origin = OriginOrAny::try_from(&header_value)?;
7375
Ok(Self(origin))
7476
}
7577
}
7678

7779
impl TryFrom<&HeaderValue> for OriginOrAny {
78-
type Error = ::Error;
80+
type Error = Error;
7981

80-
fn try_from(header_value: &HeaderValue) -> Result<Self, ::Error> {
82+
fn try_from(header_value: &HeaderValue) -> Result<Self, Error> {
8183
Origin::try_from_value(header_value)
8284
.map(OriginOrAny::Origin)
83-
.ok_or_else(::Error::invalid)
85+
.ok_or_else(Error::invalid)
8486
}
8587
}
8688

8789
impl TryFromValues for OriginOrAny {
88-
fn try_from_values<'i, I>(values: &mut I) -> Result<Self, ::Error>
90+
fn try_from_values<'i, I>(values: &mut I) -> Result<Self, Error>
8991
where
9092
I: Iterator<Item = &'i HeaderValue>,
9193
{
@@ -98,7 +100,7 @@ impl TryFromValues for OriginOrAny {
98100

99101
Origin::try_from_value(value).map(OriginOrAny::Origin)
100102
})
101-
.ok_or_else(::Error::invalid)
103+
.ok_or_else(Error::invalid)
102104
}
103105
}
104106

src/common/access_control_expose_headers.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use std::iter::FromIterator;
22

3-
use util::FlatCsv;
4-
use {HeaderName, HeaderValue};
3+
use http::{HeaderName, HeaderValue};
4+
5+
use crate::util::FlatCsv;
56

67
/// `Access-Control-Expose-Headers` header, part of
78
/// [CORS](http://www.w3.org/TR/cors/#access-control-expose-headers-response-header)

src/common/access_control_max_age.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::time::Duration;
22

3-
use util::Seconds;
3+
use crate::util::Seconds;
44

55
/// `Access-Control-Max-Age` header, part of
66
/// [CORS](http://www.w3.org/TR/cors/#access-control-max-age-response-header)

src/common/access_control_request_headers.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use std::iter::FromIterator;
22

3-
use util::FlatCsv;
4-
use {HeaderName, HeaderValue};
3+
use http::{HeaderName, HeaderValue};
4+
5+
use crate::util::FlatCsv;
56

67
/// `Access-Control-Request-Headers` header, part of
78
/// [CORS](http://www.w3.org/TR/cors/#access-control-request-headers-request-header)

src/common/access_control_request_method.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use http::Method;
2-
use {Header, HeaderName, HeaderValue};
1+
use http::{HeaderName, HeaderValue, Method};
2+
3+
use crate::{Error, Header};
34

45
/// `Access-Control-Request-Method` header, part of
56
/// [CORS](http://www.w3.org/TR/cors/#access-control-request-method-request-header)
@@ -33,15 +34,15 @@ impl Header for AccessControlRequestMethod {
3334
&::http::header::ACCESS_CONTROL_REQUEST_METHOD
3435
}
3536

36-
fn decode<'i, I: Iterator<Item = &'i HeaderValue>>(values: &mut I) -> Result<Self, ::Error> {
37+
fn decode<'i, I: Iterator<Item = &'i HeaderValue>>(values: &mut I) -> Result<Self, Error> {
3738
values
3839
.next()
3940
.and_then(|value| Method::from_bytes(value.as_bytes()).ok())
4041
.map(AccessControlRequestMethod)
41-
.ok_or_else(::Error::invalid)
42+
.ok_or_else(Error::invalid)
4243
}
4344

44-
fn encode<E: Extend<::HeaderValue>>(&self, values: &mut E) {
45+
fn encode<E: Extend<HeaderValue>>(&self, values: &mut E) {
4546
// For the more common methods, try to use a static string.
4647
let s = match self.0 {
4748
Method::GET => "GET",

0 commit comments

Comments
 (0)