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
+3 -3
View File
@@ -43,7 +43,7 @@ impl Value {
pub fn to_pretty_string(&self) -> String {
let mut wr = Vec::new();
self.to_pretty_writer(wr.by_ref()).unwrap();
str::from_utf8(wr.as_slice()).unwrap().to_string()
str::from_utf8(&wr).unwrap().to_string()
}
/// If the Json value is an Object, returns the value associated with the provided key.
@@ -130,7 +130,7 @@ impl Value {
/// Returns None otherwise.
pub fn as_string<'a>(&'a self) -> Option<&'a str> {
match *self {
Value::String(ref s) => Some(s.as_slice()),
Value::String(ref s) => Some(&s),
_ => None
}
}
@@ -212,7 +212,7 @@ impl ToString for Value {
fn to_string(&self) -> String {
let mut wr = Vec::new();
self.to_writer(wr.by_ref()).unwrap();
str::from_utf8(wr.as_slice()).unwrap().to_string()
str::from_utf8(&wr).unwrap().to_string()
}
}