mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-10 17:01:02 +00:00
Use deref coercions when possible
This commit is contained in:
+10
-10
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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<
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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",
|
||||
*/
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user