fix(rustup): Remove uses of the obsolete &a[] syntax
This commit is contained in:
committed by
Sean McArthur
parent
234fcdc3a2
commit
039e984f68
@@ -29,7 +29,7 @@ impl header::Header for AccessControlAllowOrigin {
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<AccessControlAllowOrigin> {
|
||||
if raw.len() == 1 {
|
||||
match str::from_utf8(unsafe { &raw[].get_unchecked(0)[] }) {
|
||||
match str::from_utf8(unsafe { &raw.get_unchecked(0)[..] }) {
|
||||
Ok(s) => {
|
||||
if s == "*" {
|
||||
Some(AccessControlAllowOrigin::AllowStar)
|
||||
|
||||
@@ -29,7 +29,7 @@ impl<S: Scheme + 'static> Header for Authorization<S> {
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Authorization<S>> {
|
||||
if raw.len() == 1 {
|
||||
match (from_utf8(unsafe { &raw[].get_unchecked(0)[] }), Scheme::scheme(None::<S>)) {
|
||||
match (from_utf8(unsafe { &raw.get_unchecked(0)[..] }), Scheme::scheme(None::<S>)) {
|
||||
(Ok(header), Some(scheme))
|
||||
if header.starts_with(scheme) && header.len() > scheme.len() + 1 => {
|
||||
header[scheme.len() + 1..].parse::<S>().map(|s| Authorization(s)).ok()
|
||||
@@ -96,7 +96,7 @@ impl Scheme for Basic {
|
||||
let mut text = self.username.clone();
|
||||
text.push(':');
|
||||
if let Some(ref pass) = self.password {
|
||||
text.push_str(&pass[]);
|
||||
text.push_str(&pass[..]);
|
||||
}
|
||||
write!(f, "{}", text.as_bytes().to_base64(Config {
|
||||
char_set: Standard,
|
||||
@@ -113,7 +113,7 @@ impl FromStr for Basic {
|
||||
match s.from_base64() {
|
||||
Ok(decoded) => match String::from_utf8(decoded) {
|
||||
Ok(text) => {
|
||||
let mut parts = &mut text[].split(':');
|
||||
let mut parts = &mut text.split(':');
|
||||
let user = match parts.next() {
|
||||
Some(part) => part.to_string(),
|
||||
None => return Err(())
|
||||
@@ -160,7 +160,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_raw_auth_parse() {
|
||||
let headers = Headers::from_raw(&mut mem("Authorization: foo bar baz\r\n\r\n")).unwrap();
|
||||
assert_eq!(&headers.get::<Authorization<String>>().unwrap().0[], "foo bar baz");
|
||||
assert_eq!(&headers.get::<Authorization<String>>().unwrap().0[..], "foo bar baz");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -181,7 +181,7 @@ mod tests {
|
||||
fn test_basic_auth_parse() {
|
||||
let headers = Headers::from_raw(&mut mem("Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\r\n\r\n")).unwrap();
|
||||
let auth = headers.get::<Authorization<Basic>>().unwrap();
|
||||
assert_eq!(&auth.0.username[], "Aladdin");
|
||||
assert_eq!(&auth.0.username[..], "Aladdin");
|
||||
assert_eq!(auth.0.password, Some("open sesame".to_string()));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ impl Header for CacheControl {
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<CacheControl> {
|
||||
let directives = raw.iter()
|
||||
.filter_map(|line| from_one_comma_delimited(&line[]))
|
||||
.filter_map(|line| from_one_comma_delimited(&line[..]))
|
||||
.collect::<Vec<Vec<CacheDirective>>>()
|
||||
.concat();
|
||||
if directives.len() > 0 {
|
||||
@@ -29,7 +29,7 @@ impl Header for CacheControl {
|
||||
|
||||
impl HeaderFormat for CacheControl {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt_comma_delimited(fmt, &self[])
|
||||
fmt_comma_delimited(fmt, &self[..])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ impl fmt::Display for CacheDirective {
|
||||
ProxyRevalidate => "proxy-revalidate",
|
||||
SMaxAge(secs) => return write!(f, "s-maxage={}", secs),
|
||||
|
||||
Extension(ref name, None) => &name[],
|
||||
Extension(ref name, None) => &name[..],
|
||||
Extension(ref name, Some(ref arg)) => return write!(f, "{}={}", name, arg),
|
||||
|
||||
}, f)
|
||||
|
||||
@@ -64,7 +64,7 @@ impl Header for Connection {
|
||||
impl HeaderFormat for Connection {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Connection(ref parts) = *self;
|
||||
fmt_comma_delimited(fmt, &parts[])
|
||||
fmt_comma_delimited(fmt, &parts[..])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ impl Header for Cookie {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Cookie> {
|
||||
let mut cookies = Vec::with_capacity(raw.len());
|
||||
for cookies_raw in raw.iter() {
|
||||
match from_utf8(&cookies_raw[]) {
|
||||
match from_utf8(&cookies_raw[..]) {
|
||||
Ok(cookies_str) => {
|
||||
for cookie_str in cookies_str.split(';') {
|
||||
match cookie_str.trim().parse() {
|
||||
@@ -82,7 +82,7 @@ impl Cookie {
|
||||
|
||||
#[test]
|
||||
fn test_parse() {
|
||||
let h = Header::parse_header(&[b"foo=bar; baz=quux".to_vec()][]);
|
||||
let h = Header::parse_header(&[b"foo=bar; baz=quux".to_vec()][..]);
|
||||
let c1 = CookiePair::new("foo".to_string(), "bar".to_string());
|
||||
let c2 = CookiePair::new("baz".to_string(), "quux".to_string());
|
||||
assert_eq!(h, Some(Cookie(vec![c1, c2])));
|
||||
@@ -99,7 +99,7 @@ fn test_fmt() {
|
||||
let mut headers = Headers::new();
|
||||
headers.set(cookie_header);
|
||||
|
||||
assert_eq!(&headers.to_string()[], "Cookie: foo=bar; baz=quux\r\n");
|
||||
assert_eq!(&headers.to_string()[..], "Cookie: foo=bar; baz=quux\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -28,7 +28,7 @@ impl Header for Host {
|
||||
// FIXME: use rust-url to parse this
|
||||
// https://github.com/servo/rust-url/issues/42
|
||||
let idx = {
|
||||
let slice = &s[];
|
||||
let slice = &s[..];
|
||||
if slice.char_at(1) == '[' {
|
||||
match slice.rfind(']') {
|
||||
Some(idx) => {
|
||||
|
||||
@@ -25,7 +25,7 @@ impl Header for IfMatch {
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<IfMatch> {
|
||||
from_one_raw_str(raw).and_then(|s: String| {
|
||||
let slice = &s[];
|
||||
let slice = &s[..];
|
||||
match slice {
|
||||
"" => None,
|
||||
"*" => Some(IfMatch::Any),
|
||||
@@ -39,7 +39,7 @@ impl HeaderFormat for IfMatch {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
IfMatch::Any => write!(fmt, "*"),
|
||||
IfMatch::EntityTags(ref fields) => fmt_comma_delimited(fmt, &fields[])
|
||||
IfMatch::EntityTags(ref fields) => fmt_comma_delimited(fmt, &fields[..])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ impl Header for IfNoneMatch {
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<IfNoneMatch> {
|
||||
from_one_raw_str(raw).and_then(|s: String| {
|
||||
let slice = &s[];
|
||||
let slice = &s[..];
|
||||
match slice {
|
||||
"" => None,
|
||||
"*" => Some(IfNoneMatch::Any),
|
||||
@@ -47,7 +47,7 @@ impl HeaderFormat for IfNoneMatch {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
IfNoneMatch::Any => { write!(fmt, "*") }
|
||||
IfNoneMatch::EntityTags(ref fields) => { fmt_comma_delimited(fmt, &fields[]) }
|
||||
IfNoneMatch::EntityTags(ref fields) => { fmt_comma_delimited(fmt, &fields[..]) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ macro_rules! bench_header(
|
||||
fn bench_parse(b: &mut Bencher) {
|
||||
let val = $value;
|
||||
b.iter(|| {
|
||||
let _: $ty = Header::parse_header(&val[]).unwrap();
|
||||
let _: $ty = Header::parse_header(&val[..]).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_format(b: &mut Bencher) {
|
||||
let val: $ty = Header::parse_header(&$value[]).unwrap();
|
||||
let val: $ty = Header::parse_header(&$value[..]).unwrap();
|
||||
let fmt = HeaderFormatter(&val);
|
||||
b.iter(|| {
|
||||
format!("{}", fmt);
|
||||
@@ -102,7 +102,7 @@ macro_rules! impl_list_header(
|
||||
|
||||
impl $crate::header::HeaderFormat for $from {
|
||||
fn fmt_header(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
$crate::header::parsing::fmt_comma_delimited(fmt, &self[])
|
||||
$crate::header::parsing::fmt_comma_delimited(fmt, &self[..])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Header for Pragma {
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Pragma> {
|
||||
parsing::from_one_raw_str(raw).and_then(|s: String| {
|
||||
let slice = &s.to_ascii_lowercase()[];
|
||||
let slice = &s.to_ascii_lowercase()[..];
|
||||
match slice {
|
||||
"" => None,
|
||||
"no-cache" => Some(Pragma::NoCache),
|
||||
|
||||
@@ -23,7 +23,7 @@ impl Header for SetCookie {
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<SetCookie> {
|
||||
let mut set_cookies = Vec::with_capacity(raw.len());
|
||||
for set_cookies_raw in raw.iter() {
|
||||
match from_utf8(&set_cookies_raw[]) {
|
||||
match from_utf8(&set_cookies_raw[..]) {
|
||||
Ok(s) if !s.is_empty() => {
|
||||
match s.parse() {
|
||||
Ok(cookie) => set_cookies.push(cookie),
|
||||
@@ -76,7 +76,7 @@ impl SetCookie {
|
||||
|
||||
#[test]
|
||||
fn test_parse() {
|
||||
let h = Header::parse_header(&[b"foo=bar; HttpOnly".to_vec()][]);
|
||||
let h = Header::parse_header(&[b"foo=bar; HttpOnly".to_vec()][..]);
|
||||
let mut c1 = Cookie::new("foo".to_string(), "bar".to_string());
|
||||
c1.httponly = true;
|
||||
|
||||
@@ -94,7 +94,7 @@ fn test_fmt() {
|
||||
let mut headers = Headers::new();
|
||||
headers.set(cookies);
|
||||
|
||||
assert_eq!(&headers.to_string()[], "Set-Cookie: foo=bar; HttpOnly; Path=/p\r\nSet-Cookie: baz=quux; Path=/\r\n");
|
||||
assert_eq!(&headers.to_string()[..], "Set-Cookie: foo=bar; HttpOnly; Path=/p\r\nSet-Cookie: baz=quux; Path=/\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -55,7 +55,7 @@ impl Header for Upgrade {
|
||||
impl HeaderFormat for Upgrade {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Upgrade(ref parts) = *self;
|
||||
fmt_comma_delimited(fmt, &parts[])
|
||||
fmt_comma_delimited(fmt, &parts[..])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Header for Vary {
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> Option<Vary> {
|
||||
from_one_raw_str(raw).and_then(|s: String| {
|
||||
let slice = &s[];
|
||||
let slice = &s[..];
|
||||
match slice {
|
||||
"" => None,
|
||||
"*" => Some(Vary::Any),
|
||||
@@ -35,7 +35,7 @@ impl HeaderFormat for Vary {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
Vary::Any => { write!(fmt, "*") }
|
||||
Vary::Headers(ref fields) => { fmt_comma_delimited(fmt, &fields[]) }
|
||||
Vary::Headers(ref fields) => { fmt_comma_delimited(fmt, &fields[..]) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user