diff --git a/src/form_urlencoded.rs b/src/form_urlencoded.rs index 4f0851a4b..5ea13e441 100644 --- a/src/form_urlencoded.rs +++ b/src/form_urlencoded.rs @@ -52,10 +52,7 @@ pub fn parse_bytes(input: &[u8], encoding_override: Option, } else { let (name, value) = match piece.position_elem(&b'=') { Some(position) => (piece.slice_to(position), piece.slice_from(position + 1)), - None => { - let tmp: (&[u8], &[u8]) = if isindex { (&[], piece) } else { (piece, &[]) }; - tmp - } + None => if isindex { ([].as_slice(), piece) } else { (piece, [].as_slice()) } }; let name = replace_plus(name); let value = replace_plus(value); diff --git a/src/lib.rs b/src/lib.rs index 779b85589..0a09b4d42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,9 +58,9 @@ let issue_list_url = Url::parse( assert!(issue_list_url.scheme == "https".to_string()); assert!(issue_list_url.domain() == Some("github.com")); assert!(issue_list_url.port() == None); -assert!(issue_list_url.path() == Some(&["rust-lang".to_string(), +assert!(issue_list_url.path() == Some(["rust-lang".to_string(), "rust".to_string(), - "issues".to_string()])); + "issues".to_string()].as_slice())); assert!(issue_list_url.query == Some("labels=E-easy&state=open".to_string())); assert!(issue_list_url.fragment == None); match issue_list_url.scheme_data { diff --git a/src/tests.rs b/src/tests.rs index 416c3f43f..3e11f4531 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -210,7 +210,7 @@ fn file_paths() { let mut url = Url::from_file_path(&path::posix::Path::new("/foo/bar")).unwrap(); assert_eq!(url.host(), Some(&Domain("".to_string()))); - assert_eq!(url.path(), Some(&["foo".to_string(), "bar".to_string()])); + assert_eq!(url.path(), Some(["foo".to_string(), "bar".to_string()].as_slice())); assert!(url.to_file_path() == Ok(path::posix::Path::new("/foo/bar"))); *url.path_mut().unwrap().get_mut(1) = "ba\0r".to_string(); @@ -226,7 +226,7 @@ fn file_paths() { let mut url = Url::from_file_path(&path::windows::Path::new(r"C:\foo\bar")).unwrap(); assert_eq!(url.host(), Some(&Domain("".to_string()))); - assert_eq!(url.path(), Some(&["C:".to_string(), "foo".to_string(), "bar".to_string()])); + assert_eq!(url.path(), Some(["C:".to_string(), "foo".to_string(), "bar".to_string()].as_slice())); assert!(url.to_file_path::() == Ok(path::windows::Path::new(r"C:\foo\bar"))); @@ -253,10 +253,10 @@ fn directory_paths() { let url = Url::from_directory_path(&path::posix::Path::new("/foo/bar")).unwrap(); assert_eq!(url.host(), Some(&Domain("".to_string()))); - assert_eq!(url.path(), Some(&["foo".to_string(), "bar".to_string(), "".to_string()])); + assert_eq!(url.path(), Some(["foo".to_string(), "bar".to_string(), "".to_string()].as_slice())); let url = Url::from_directory_path(&path::windows::Path::new(r"C:\foo\bar")).unwrap(); assert_eq!(url.host(), Some(&Domain("".to_string()))); - assert_eq!(url.path(), Some(&[ - "C:".to_string(), "foo".to_string(), "bar".to_string(), "".to_string()])); + assert_eq!(url.path(), Some([ + "C:".to_string(), "foo".to_string(), "bar".to_string(), "".to_string()].as_slice())); }