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
+10 -10
View File
@@ -1247,19 +1247,19 @@ fn manual_serialize_escape<W: Writer>(wr: &mut W, log: &Log) {
wr.write_str(",").unwrap();
escape_str(wr, "content_type").unwrap();
wr.write_str(":").unwrap();
escape_str(wr, log.http.content_type.as_slice()).unwrap();
escape_str(wr, &log.http.content_type).unwrap();
wr.write_str(",").unwrap();
escape_str(wr, "user_agent").unwrap();
wr.write_str(":").unwrap();
escape_str(wr, log.http.user_agent.as_slice()).unwrap();
escape_str(wr, &log.http.user_agent).unwrap();
wr.write_str(",").unwrap();
escape_str(wr, "referer").unwrap();
wr.write_str(":").unwrap();
escape_str(wr, log.http.referer.as_slice()).unwrap();
escape_str(wr, &log.http.referer).unwrap();
wr.write_str(",").unwrap();
escape_str(wr, "request_uri").unwrap();
wr.write_str(":").unwrap();
escape_str(wr, log.http.request_uri.as_slice()).unwrap();
escape_str(wr, &log.http.request_uri).unwrap();
wr.write_str("},").unwrap();
escape_str(wr, "origin").unwrap();
@@ -1267,7 +1267,7 @@ fn manual_serialize_escape<W: Writer>(wr: &mut W, log: &Log) {
escape_str(wr, "ip").unwrap();
wr.write_str(":").unwrap();
escape_str(wr, log.origin.ip.as_slice()).unwrap();
escape_str(wr, &log.origin.ip).unwrap();
wr.write_str(",").unwrap();
escape_str(wr, "port").unwrap();
wr.write_str(":").unwrap();
@@ -1275,7 +1275,7 @@ fn manual_serialize_escape<W: Writer>(wr: &mut W, log: &Log) {
wr.write_str(",").unwrap();
escape_str(wr, "hostname").unwrap();
wr.write_str(":").unwrap();
escape_str(wr, log.origin.hostname.as_slice()).unwrap();
escape_str(wr, &log.origin.hostname).unwrap();
wr.write_str(",").unwrap();
escape_str(wr, "protocol").unwrap();
wr.write_str(":").unwrap();
@@ -1292,15 +1292,15 @@ fn manual_serialize_escape<W: Writer>(wr: &mut W, log: &Log) {
wr.write_str(",").unwrap();
escape_str(wr, "server_ip").unwrap();
wr.write_str(":").unwrap();
escape_str(wr, log.server_ip.as_slice()).unwrap();
escape_str(wr, &log.server_ip).unwrap();
wr.write_str(",").unwrap();
escape_str(wr, "server_name").unwrap();
wr.write_str(":").unwrap();
escape_str(wr, log.server_name.as_slice()).unwrap();
escape_str(wr, &log.server_name).unwrap();
wr.write_str(",").unwrap();
escape_str(wr, "remote_ip").unwrap();
wr.write_str(":").unwrap();
escape_str(wr, log.remote_ip.as_slice()).unwrap();
escape_str(wr, &log.remote_ip).unwrap();
wr.write_str(",").unwrap();
escape_str(wr, "bytes_dlv").unwrap();
wr.write_str(":").unwrap();
@@ -1309,7 +1309,7 @@ fn manual_serialize_escape<W: Writer>(wr: &mut W, log: &Log) {
wr.write_str(",").unwrap();
escape_str(wr, "ray_id").unwrap();
wr.write_str(":").unwrap();
escape_str(wr, log.ray_id.as_slice()).unwrap();
escape_str(wr, &log.ray_id).unwrap();
wr.write_str("}").unwrap();
}
+3 -3
View File
@@ -315,7 +315,7 @@ fn deserialize_substructure(cx: &mut ExtCtxt, span: Span,
cx,
span,
substr.type_ident,
fields.as_slice(),
&fields,
deserializer,
token)
}
@@ -460,7 +460,7 @@ fn deserialize_struct_from_map(
{
let key = match token {
::serde2::de::Str(s) => s,
::serde2::de::String(ref s) => s.as_slice(),
::serde2::de::String(ref s) => &s,
token => {
let expected_tokens = [
::serde2::de::StrKind,
@@ -552,7 +552,7 @@ fn deserialize_static_fields(
getarg(
cx,
span,
token::intern_and_get_ident(format!("_field{}", i).as_slice())
token::intern_and_get_ident(&format!("_field{}", i))
)
}).collect();
+1 -1
View File
@@ -139,7 +139,7 @@ pub trait Visitor {
fn visit_string<
E: Error,
>(&mut self, v: String) -> Result<Self::Value, E> {
self.visit_str(&v[])
self.visit_str(&v)
}
fn visit_unit<
+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)