You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
158 lines
5.6 KiB
158 lines
5.6 KiB
7 years ago
|
From 246a3a0076a731ed919d6d10669150e3872ed049 Mon Sep 17 00:00:00 2001
|
||
|
From: Sean McArthur <sean@seanmonstar.com>
|
||
|
Date: Fri, 6 Apr 2018 11:21:17 -0700
|
||
|
Subject: [PATCH] fix conflicts with new TryFrom trait, deprecated AsciiExt
|
||
|
(#194)
|
||
|
|
||
|
---
|
||
|
src/header/name.rs | 4 ++--
|
||
|
src/method.rs | 4 ++--
|
||
|
src/request.rs | 8 ++++----
|
||
|
src/response.rs | 6 +++---
|
||
|
src/uri/authority.rs | 3 ++-
|
||
|
src/uri/mod.rs | 3 ++-
|
||
|
src/uri/scheme.rs | 3 ++-
|
||
|
7 files changed, 17 insertions(+), 14 deletions(-)
|
||
|
|
||
|
diff --git a/src/header/name.rs b/src/header/name.rs
|
||
|
index 71ae5184d9a6..4596f2cda1c1 100644
|
||
|
--- a/src/header/name.rs
|
||
|
+++ b/src/header/name.rs
|
||
|
@@ -125,14 +125,14 @@ macro_rules! standard_headers {
|
||
|
let bytes: Bytes =
|
||
|
HeaderName::from_bytes(name_bytes).unwrap().into();
|
||
|
assert_eq!(bytes, name_bytes);
|
||
|
- assert_eq!(HeaderName::try_from(Bytes::from(name_bytes)).unwrap(), std);
|
||
|
+ assert_eq!(HeaderName::from_bytes(name_bytes).unwrap(), std);
|
||
|
|
||
|
// Test upper case
|
||
|
let upper = name.to_uppercase().to_string();
|
||
|
let bytes: Bytes =
|
||
|
HeaderName::from_bytes(upper.as_bytes()).unwrap().into();
|
||
|
assert_eq!(bytes, name.as_bytes());
|
||
|
- assert_eq!(HeaderName::try_from(Bytes::from(upper.as_bytes())).unwrap(),
|
||
|
+ assert_eq!(HeaderName::from_bytes(upper.as_bytes()).unwrap(),
|
||
|
std);
|
||
|
|
||
|
|
||
|
diff --git a/src/method.rs b/src/method.rs
|
||
|
index 6f28fef840c2..d8f1bfbfb72c 100644
|
||
|
--- a/src/method.rs
|
||
|
+++ b/src/method.rs
|
||
|
@@ -322,7 +322,7 @@ impl<'a> HttpTryFrom<&'a str> for Method {
|
||
|
|
||
|
#[inline]
|
||
|
fn try_from(t: &'a str) -> Result<Self, Self::Error> {
|
||
|
- Method::try_from(t.as_bytes())
|
||
|
+ HttpTryFrom::try_from(t.as_bytes())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@@ -331,7 +331,7 @@ impl FromStr for Method {
|
||
|
|
||
|
#[inline]
|
||
|
fn from_str(t: &str) -> Result<Self, Self::Err> {
|
||
|
- Method::try_from(t)
|
||
|
+ HttpTryFrom::try_from(t)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
diff --git a/src/request.rs b/src/request.rs
|
||
|
index 7917b1465b20..b71d38e15f0a 100644
|
||
|
--- a/src/request.rs
|
||
|
+++ b/src/request.rs
|
||
|
@@ -764,7 +764,7 @@ impl Builder {
|
||
|
where Method: HttpTryFrom<T>,
|
||
|
{
|
||
|
if let Some(head) = head(&mut self.head, &self.err) {
|
||
|
- match Method::try_from(method) {
|
||
|
+ match HttpTryFrom::try_from(method) {
|
||
|
Ok(s) => head.method = s,
|
||
|
Err(e) => self.err = Some(e.into()),
|
||
|
}
|
||
|
@@ -793,7 +793,7 @@ impl Builder {
|
||
|
where Uri: HttpTryFrom<T>,
|
||
|
{
|
||
|
if let Some(head) = head(&mut self.head, &self.err) {
|
||
|
- match Uri::try_from(uri) {
|
||
|
+ match HttpTryFrom::try_from(uri) {
|
||
|
Ok(s) => head.uri = s,
|
||
|
Err(e) => self.err = Some(e.into()),
|
||
|
}
|
||
|
@@ -848,9 +848,9 @@ impl Builder {
|
||
|
HeaderValue: HttpTryFrom<V>
|
||
|
{
|
||
|
if let Some(head) = head(&mut self.head, &self.err) {
|
||
|
- match HeaderName::try_from(key) {
|
||
|
+ match <HeaderName as HttpTryFrom<K>>::try_from(key) {
|
||
|
Ok(key) => {
|
||
|
- match HeaderValue::try_from(value) {
|
||
|
+ match <HeaderValue as HttpTryFrom<V>>::try_from(value) {
|
||
|
Ok(value) => { head.headers.append(key, value); }
|
||
|
Err(e) => self.err = Some(e.into()),
|
||
|
}
|
||
|
diff --git a/src/response.rs b/src/response.rs
|
||
|
index cb780dce37f4..edfbb56b4e20 100644
|
||
|
--- a/src/response.rs
|
||
|
+++ b/src/response.rs
|
||
|
@@ -561,7 +561,7 @@ impl Builder {
|
||
|
where StatusCode: HttpTryFrom<T>,
|
||
|
{
|
||
|
if let Some(head) = head(&mut self.head, &self.err) {
|
||
|
- match StatusCode::try_from(status) {
|
||
|
+ match HttpTryFrom::try_from(status) {
|
||
|
Ok(s) => head.status = s,
|
||
|
Err(e) => self.err = Some(e.into()),
|
||
|
}
|
||
|
@@ -616,9 +616,9 @@ impl Builder {
|
||
|
HeaderValue: HttpTryFrom<V>
|
||
|
{
|
||
|
if let Some(head) = head(&mut self.head, &self.err) {
|
||
|
- match HeaderName::try_from(key) {
|
||
|
+ match <HeaderName as HttpTryFrom<K>>::try_from(key) {
|
||
|
Ok(key) => {
|
||
|
- match HeaderValue::try_from(value) {
|
||
|
+ match <HeaderValue as HttpTryFrom<V>>::try_from(value) {
|
||
|
Ok(value) => { head.headers.append(key, value); }
|
||
|
Err(e) => self.err = Some(e.into()),
|
||
|
}
|
||
|
diff --git a/src/uri/authority.rs b/src/uri/authority.rs
|
||
|
index 89229b109fc7..1fd78704e832 100644
|
||
|
--- a/src/uri/authority.rs
|
||
|
+++ b/src/uri/authority.rs
|
||
|
@@ -1,4 +1,5 @@
|
||
|
-#[allow(unused)]
|
||
|
+// Deprecated in 1.26, needed until our minimum version is >=1.23.
|
||
|
+#[allow(unused, deprecated)]
|
||
|
use std::ascii::AsciiExt;
|
||
|
use std::{cmp, fmt, str};
|
||
|
use std::hash::{Hash, Hasher};
|
||
|
diff --git a/src/uri/mod.rs b/src/uri/mod.rs
|
||
|
index bd980b592723..85b276bd9763 100644
|
||
|
--- a/src/uri/mod.rs
|
||
|
+++ b/src/uri/mod.rs
|
||
|
@@ -28,7 +28,8 @@ use byte_str::ByteStr;
|
||
|
use bytes::Bytes;
|
||
|
|
||
|
use std::{fmt, u8, u16};
|
||
|
-#[allow(unused)]
|
||
|
+// Deprecated in 1.26, needed until our minimum version is >=1.23.
|
||
|
+#[allow(unused, deprecated)]
|
||
|
use std::ascii::AsciiExt;
|
||
|
use std::hash::{Hash, Hasher};
|
||
|
use std::str::{self, FromStr};
|
||
|
diff --git a/src/uri/scheme.rs b/src/uri/scheme.rs
|
||
|
index ae40ff6ece31..5fa1e9bb0675 100644
|
||
|
--- a/src/uri/scheme.rs
|
||
|
+++ b/src/uri/scheme.rs
|
||
|
@@ -1,4 +1,5 @@
|
||
|
-#[allow(unused)]
|
||
|
+// Deprecated in 1.26, needed until our minimum version is >=1.23.
|
||
|
+#[allow(unused, deprecated)]
|
||
|
use std::ascii::AsciiExt;
|
||
|
use std::fmt;
|
||
|
use std::hash::{Hash, Hasher};
|
||
|
--
|
||
|
2.17.0
|
||
|
|