fix(rustup): update to rust beta

This commit is contained in:
Sean McArthur
2015-04-02 12:32:46 -07:00
parent b4aeeb347c
commit 0f5858f379
12 changed files with 79 additions and 74 deletions

View File

@@ -1,4 +1,7 @@
use std::fmt;
use std::str;
use unicase::UniCase;
use header::{Header, HeaderFormat};
@@ -16,14 +19,29 @@ pub enum Expect {
Continue
}
const EXPECT_CONTINUE: UniCase<&'static str> = UniCase("100-continue");
impl Header for Expect {
fn header_name() -> &'static str {
"Expect"
}
fn parse_header(raw: &[Vec<u8>]) -> Option<Expect> {
if &[b"100-continue"] == raw {
Some(Expect::Continue)
if raw.len() == 1 {
let text = unsafe {
// safe because:
// 1. we just checked raw.len == 1
// 2. we don't actually care if it's utf8, we just want to
// compare the bytes with the "case" normalized. If it's not
// utf8, then the byte comparison will fail, and we'll return
// None. No big deal.
str::from_utf8_unchecked(raw.get_unchecked(0))
};
if UniCase(text) == EXPECT_CONTINUE {
Some(Expect::Continue)
} else {
None
}
} else {
None
}

View File

@@ -141,11 +141,11 @@ mod tests {
#[test]
fn test_etag_parse_success() {
// Expected success
assert_eq!("\"foobar\"".parse().unwrap(), EntityTag::new(false, "foobar".to_string()));
assert_eq!("\"\"".parse().unwrap(), EntityTag::new(false, "".to_string()));
assert_eq!("W/\"weaktag\"".parse().unwrap(), EntityTag::new(true, "weaktag".to_string()));
assert_eq!("W/\"\x65\x62\"".parse().unwrap(), EntityTag::new(true, "\x65\x62".to_string()));
assert_eq!("W/\"\"".parse().unwrap(), EntityTag::new(true, "".to_string()));
assert_eq!("\"foobar\"".parse::<EntityTag>().unwrap(), EntityTag::new(false, "foobar".to_string()));
assert_eq!("\"\"".parse::<EntityTag>().unwrap(), EntityTag::new(false, "".to_string()));
assert_eq!("W/\"weaktag\"".parse::<EntityTag>().unwrap(), EntityTag::new(true, "weaktag".to_string()));
assert_eq!("W/\"\x65\x62\"".parse::<EntityTag>().unwrap(), EntityTag::new(true, "\x65\x62".to_string()));
assert_eq!("W/\"\"".parse::<EntityTag>().unwrap(), EntityTag::new(true, "".to_string()));
}
#[test]

View File

@@ -114,7 +114,7 @@ impl<T: str::FromStr> str::FromStr for QualityItem<T> {
let mut raw_item = s;
let mut quality = 1f32;
let parts: Vec<&str> = s.rsplitn(1, ';').map(|x| x.trim()).collect();
let parts: Vec<&str> = s.rsplitn(2, ';').map(|x| x.trim()).collect();
if parts.len() == 2 {
let start = &parts[0][0..2];
if start == "q=" || start == "Q=" {