From e5ddf759de3af69324016058e4e1b29400101ede Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Fri, 5 Dec 2014 22:33:30 -0800 Subject: [PATCH] cleanup serde::json::value --- src/json/value.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/json/value.rs b/src/json/value.rs index 9f43d58b..473c3633 100644 --- a/src/json/value.rs +++ b/src/json/value.rs @@ -20,9 +20,9 @@ pub enum Value { Boolean(bool), Integer(i64), Floating(f64), - String(string::String), + String(String), Array(Vec), - Object(TreeMap), + Object(TreeMap), } impl Value { @@ -40,7 +40,7 @@ impl Value { } /// Serializes a json value into a string - pub fn to_pretty_string(&self) -> string::String { + 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() @@ -48,7 +48,7 @@ impl Value { /// If the Json value is an Object, returns the value associated with the provided key. /// Otherwise, returns None. - pub fn find<'a>(&'a self, key: &string::String) -> Option<&'a Value>{ + pub fn find<'a>(&'a self, key: &String) -> Option<&'a Value>{ match self { &Value::Object(ref map) => map.get(key), _ => None @@ -58,7 +58,7 @@ impl Value { /// Attempts to get a nested Json Object for each key in `keys`. /// If any key is found not to exist, find_path will return None. /// Otherwise, it will return the Json value associated with the final key. - pub fn find_path<'a>(&'a self, keys: &[&string::String]) -> Option<&'a Value>{ + pub fn find_path<'a>(&'a self, keys: &[&String]) -> Option<&'a Value>{ let mut target = self; for key in keys.iter() { match target.find(*key) { @@ -72,7 +72,7 @@ impl Value { /// If the Json value is an Object, performs a depth-first search until /// a value associated with the provided key is found. If no value is found /// or the Json value is not an Object, returns None. - pub fn search<'a>(&'a self, key: &string::String) -> Option<&'a Value> { + pub fn search<'a>(&'a self, key: &String) -> Option<&'a Value> { match self { &Value::Object(ref map) => { match map.get(key) { @@ -100,7 +100,7 @@ impl Value { /// If the Json value is an Object, returns the associated TreeMap. /// Returns None otherwise. - pub fn as_object<'a>(&'a self) -> Option<&'a TreeMap> { + pub fn as_object<'a>(&'a self) -> Option<&'a TreeMap> { match *self { Value::Object(ref map) => Some(map), _ => None @@ -304,7 +304,7 @@ impl, E> de::Deserialize for Value { enum State { Value(Value), Array(vec::MoveItems), - Object(tree_map::MoveEntries), + Object(tree_map::MoveEntries), End, } @@ -580,7 +580,7 @@ impl<'a> ToJson for &'a str { fn to_json(&self) -> Value { Value::String(self.to_string()) } } -impl ToJson for string::String { +impl ToJson for String { fn to_json(&self) -> Value { Value::String((*self).clone()) } } @@ -628,7 +628,7 @@ impl ToJson for Vec { } } -impl ToJson for TreeMap { +impl ToJson for TreeMap { fn to_json(&self) -> Value { let mut d = TreeMap::new(); for (key, value) in self.iter() { @@ -638,7 +638,7 @@ impl ToJson for TreeMap { } } -impl ToJson for HashMap { +impl ToJson for HashMap { fn to_json(&self) -> Value { let mut d = TreeMap::new(); for (key, value) in self.iter() {