Use deref coercions when possible

This commit is contained in:
Thomas Bahn
2015-02-06 14:08:02 +01:00
parent 361acd37d0
commit 3022d7301a
14 changed files with 54 additions and 54 deletions
+2 -2
View File
@@ -106,7 +106,7 @@ impl<Iter: Iterator<Item=u8>> Parser<Iter> {
b'0' ... b'9' | b'-' => self.parse_number(visitor),
b'"' => {
try!(self.parse_string());
let s = str::from_utf8(self.buf.as_slice()).unwrap();
let s = str::from_utf8(&self.buf).unwrap();
visitor.visit_str(s)
}
b'[' => {
@@ -334,7 +334,7 @@ impl<Iter: Iterator<Item=u8>> Parser<Iter> {
}
let buf = &[n1, try!(self.decode_hex_escape())];
match ::unicode::str::utf16_items(buf.as_slice()).next() {
match ::unicode::str::utf16_items(buf).next() {
Some(Utf16Item::ScalarValue(c)) => c,
_ => {
return Err(self.error(ErrorCode::LoneLeadingSurrogateInHexEscape));
+1 -1
View File
@@ -93,7 +93,7 @@ impl error::Error for Error {
Error::SyntaxError(..) => "syntax error",
Error::IoError(ref error) => error.description(),
/*
Error::ExpectedError(ref expected, _) => expected.as_slice(),
Error::ExpectedError(ref expected, _) => &expected,
Error::MissingFieldError(_) => "missing field",
Error::UnknownVariantError(_) => "unknown variant",
*/
+1 -1
View File
@@ -35,7 +35,7 @@ impl ser::Serialize for Value {
visitor.visit_f64(v)
}
Value::String(ref v) => {
visitor.visit_str(v.as_slice())
visitor.visit_str(&v)
}
Value::Array(ref v) => {
v.visit(visitor)