fix(rustup): get rid of slice pattern, add Reflect bounds

* remove slice pattern
* add `Reflect` trait bounds where necessary
This commit is contained in:
Florian Hartwig
2015-03-29 18:01:05 +02:00
parent 8e1cd5e6e2
commit c9f2c841ff
3 changed files with 23 additions and 21 deletions

View File

@@ -53,21 +53,21 @@ impl FromStr for RequestUri {
type Err = HttpError;
fn from_str(s: &str) -> Result<RequestUri, HttpError> {
match s.as_bytes() {
[] => Err(HttpError::HttpUriError(UrlError::InvalidCharacter)),
[b'*'] => Ok(RequestUri::Star),
[b'/', ..] => Ok(RequestUri::AbsolutePath(s.to_string())),
bytes if bytes.contains(&b'/') => {
Ok(RequestUri::AbsoluteUri(try!(Url::parse(s))))
}
_ => {
let mut temp = "http://".to_string();
temp.push_str(s);
try!(Url::parse(&temp[..]));
todo!("compare vs u.authority()");
Ok(RequestUri::Authority(s.to_string()))
}
let bytes = s.as_bytes();
if bytes == [] {
Err(HttpError::HttpUriError(UrlError::InvalidCharacter))
} else if bytes == b"*" {
Ok(RequestUri::Star)
} else if bytes.starts_with(b"/") {
Ok(RequestUri::AbsolutePath(s.to_string()))
} else if bytes.contains(&b'/') {
Ok(RequestUri::AbsoluteUri(try!(Url::parse(s))))
} else {
let mut temp = "http://".to_string();
temp.push_str(s);
try!(Url::parse(&temp[..]));
todo!("compare vs u.authority()");
Ok(RequestUri::Authority(s.to_string()))
}
}
}