refactor(headers): remove usage of deprecated ascii trait

This commit is contained in:
Niv Kaminer
2018-08-03 21:54:34 +03:00
committed by Sean McArthur
parent 4290b8bba4
commit 97f4243a59

View File

@@ -14,7 +14,7 @@ pub fn connection_close(value: &HeaderValue) -> bool {
fn connection_has(value: &HeaderValue, needle: &str) -> bool {
if let Ok(s) = value.to_str() {
for val in s.split(',') {
if eq_ascii(val.trim(), needle) {
if val.trim().eq_ignore_ascii_case(needle) {
return true;
}
}
@@ -87,7 +87,7 @@ pub fn is_chunked_(value: &HeaderValue) -> bool {
// chunked must always be the last encoding, according to spec
if let Ok(s) = value.to_str() {
if let Some(encoding) = s.rsplit(',').next() {
return eq_ascii(encoding.trim(), "chunked");
return encoding.trim().eq_ignore_ascii_case("chunked");
}
}
@@ -112,14 +112,3 @@ pub fn add_chunked(mut entry: OccupiedEntry<HeaderValue>) {
entry.insert(HeaderValue::from_static(CHUNKED));
}
fn eq_ascii(left: &str, right: &str) -> bool {
// As of Rust 1.23, str gained this method inherently, and so the
// compiler says this trait is unused.
//
// TODO: Once our minimum Rust compiler version is >=1.23, this can be removed.
#[allow(unused, deprecated)]
use std::ascii::AsciiExt;
left.eq_ignore_ascii_case(right)
}