Update for latest rust
Tracks rust nightly. 7 tests fail -- still finding source
This commit is contained in:
@@ -23,18 +23,24 @@ pub enum Encoding {
|
||||
EncodingExt(String)
|
||||
}
|
||||
|
||||
impl fmt::Show for Encoding {
|
||||
impl fmt::String for Encoding {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
write!(fmt, "{}", match *self {
|
||||
Chunked => "chunked",
|
||||
Gzip => "gzip",
|
||||
Deflate => "deflate",
|
||||
Compress => "compress",
|
||||
Identity => "identity",
|
||||
EncodingExt(ref s) => s.as_slice()
|
||||
}.fmt(fmt)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Show for Encoding {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.to_string().fmt(fmt)
|
||||
}
|
||||
}
|
||||
|
||||
impl str::FromStr for Encoding {
|
||||
fn from_str(s: &str) -> Option<Encoding> {
|
||||
|
||||
@@ -26,7 +26,13 @@ impl<T> QualityItem<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::Show> fmt::Show for QualityItem<T> {
|
||||
impl<T: fmt::String> fmt::String for QualityItem<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}; q={}", self.item, format!("{:.3}", self.quality).trim_right_matches(['0', '.'].as_slice()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::String> fmt::Show for QualityItem<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}; q={}", self.item, format!("{:.3}", self.quality).trim_right_matches(['0', '.'].as_slice()))
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ pub fn from_one_raw_str<T: str::FromStr>(raw: &[Vec<u8>]) -> Option<T> {
|
||||
return None;
|
||||
}
|
||||
// we JUST checked that raw.len() == 1, so raw[0] WILL exist.
|
||||
match str::from_utf8(raw[0][]) {
|
||||
match str::from_utf8(&raw[0][]) {
|
||||
Ok(s) => str::FromStr::from_str(s),
|
||||
Err(_) => None
|
||||
}
|
||||
@@ -22,7 +22,7 @@ pub fn from_comma_delimited<T: str::FromStr>(raw: &[Vec<u8>]) -> Option<Vec<T>>
|
||||
return None;
|
||||
}
|
||||
// we JUST checked that raw.len() == 1, so raw[0] WILL exist.
|
||||
from_one_comma_delimited(raw[0][])
|
||||
from_one_comma_delimited(&raw[0][])
|
||||
}
|
||||
|
||||
/// Reads a comma-delimited raw string into a Vec.
|
||||
@@ -40,7 +40,7 @@ pub fn from_one_comma_delimited<T: str::FromStr>(raw: &[u8]) -> Option<Vec<T>> {
|
||||
}
|
||||
|
||||
/// Format an array into a comma-delimited string.
|
||||
pub fn fmt_comma_delimited<T: fmt::Show>(fmt: &mut fmt::Formatter, parts: &[T]) -> fmt::Result {
|
||||
pub fn fmt_comma_delimited<T: fmt::String>(fmt: &mut fmt::Formatter, parts: &[T]) -> fmt::Result {
|
||||
let last = parts.len() - 1;
|
||||
for (i, part) in parts.iter().enumerate() {
|
||||
try!(write!(fmt, "{}", part));
|
||||
|
||||
Reference in New Issue
Block a user