diff options
| author | Richo Healey <richo@psych0tik.net> | 2014-06-21 03:39:03 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2014-07-08 13:01:43 -0700 |
| commit | 12c334a77b897f7b1cb6cff3c56a71ecb89c82af (patch) | |
| tree | 1f5a85061a69058875391ec6171cf8b446996dff /src/libserialize | |
| parent | bfe4ddfdea45533c98657701509bb7185fd96cba (diff) | |
| download | rust-12c334a77b897f7b1cb6cff3c56a71ecb89c82af.tar.gz rust-12c334a77b897f7b1cb6cff3c56a71ecb89c82af.zip | |
std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.
[breaking-change]
Diffstat (limited to 'src/libserialize')
| -rw-r--r-- | src/libserialize/json.rs | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index f4e5c27a14b..df4d3437b1c 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -130,7 +130,7 @@ fn main() { // Serialize using `ToJson` let test2 = TestStruct1 {data_int: 1, data_str:"toto".to_string(), data_vector:vec![2,3,4,5]}; let tjson: json::Json = test2.to_json(); - let json_str: String = tjson.to_str(); + let json_str: String = tjson.to_string(); // Deserialize like before let decoded: TestStruct1 = json::decode(json_str.as_slice()).unwrap(); @@ -2202,59 +2202,59 @@ mod tests { #[test] fn test_write_null() { - assert_eq!(Null.to_str().into_string(), "null".to_string()); + assert_eq!(Null.to_string().into_string(), "null".to_string()); assert_eq!(Null.to_pretty_str().into_string(), "null".to_string()); } #[test] fn test_write_number() { - assert_eq!(Number(3.0).to_str().into_string(), "3".to_string()); + assert_eq!(Number(3.0).to_string().into_string(), "3".to_string()); assert_eq!(Number(3.0).to_pretty_str().into_string(), "3".to_string()); - assert_eq!(Number(3.1).to_str().into_string(), "3.1".to_string()); + assert_eq!(Number(3.1).to_string().into_string(), "3.1".to_string()); assert_eq!(Number(3.1).to_pretty_str().into_string(), "3.1".to_string()); - assert_eq!(Number(-1.5).to_str().into_string(), "-1.5".to_string()); + assert_eq!(Number(-1.5).to_string().into_string(), "-1.5".to_string()); assert_eq!(Number(-1.5).to_pretty_str().into_string(), "-1.5".to_string()); - assert_eq!(Number(0.5).to_str().into_string(), "0.5".to_string()); + assert_eq!(Number(0.5).to_string().into_string(), "0.5".to_string()); assert_eq!(Number(0.5).to_pretty_str().into_string(), "0.5".to_string()); - assert_eq!(Number(f64::NAN).to_str().into_string(), "null".to_string()); + assert_eq!(Number(f64::NAN).to_string().into_string(), "null".to_string()); assert_eq!(Number(f64::NAN).to_pretty_str().into_string(), "null".to_string()); - assert_eq!(Number(f64::INFINITY).to_str().into_string(), "null".to_string()); + assert_eq!(Number(f64::INFINITY).to_string().into_string(), "null".to_string()); assert_eq!(Number(f64::INFINITY).to_pretty_str().into_string(), "null".to_string()); - assert_eq!(Number(f64::NEG_INFINITY).to_str().into_string(), "null".to_string()); + assert_eq!(Number(f64::NEG_INFINITY).to_string().into_string(), "null".to_string()); assert_eq!(Number(f64::NEG_INFINITY).to_pretty_str().into_string(), "null".to_string()); } #[test] fn test_write_str() { - assert_eq!(String("".to_string()).to_str().into_string(), "\"\"".to_string()); + assert_eq!(String("".to_string()).to_string().into_string(), "\"\"".to_string()); assert_eq!(String("".to_string()).to_pretty_str().into_string(), "\"\"".to_string()); - assert_eq!(String("foo".to_string()).to_str().into_string(), "\"foo\"".to_string()); + assert_eq!(String("foo".to_string()).to_string().into_string(), "\"foo\"".to_string()); assert_eq!(String("foo".to_string()).to_pretty_str().into_string(), "\"foo\"".to_string()); } #[test] fn test_write_bool() { - assert_eq!(Boolean(true).to_str().into_string(), "true".to_string()); + assert_eq!(Boolean(true).to_string().into_string(), "true".to_string()); assert_eq!(Boolean(true).to_pretty_str().into_string(), "true".to_string()); - assert_eq!(Boolean(false).to_str().into_string(), "false".to_string()); + assert_eq!(Boolean(false).to_string().into_string(), "false".to_string()); assert_eq!(Boolean(false).to_pretty_str().into_string(), "false".to_string()); } #[test] fn test_write_list() { - assert_eq!(List(vec![]).to_str().into_string(), "[]".to_string()); + assert_eq!(List(vec![]).to_string().into_string(), "[]".to_string()); assert_eq!(List(vec![]).to_pretty_str().into_string(), "[]".to_string()); - assert_eq!(List(vec![Boolean(true)]).to_str().into_string(), "[true]".to_string()); + assert_eq!(List(vec![Boolean(true)]).to_string().into_string(), "[true]".to_string()); assert_eq!( List(vec![Boolean(true)]).to_pretty_str().into_string(), "\ @@ -2268,7 +2268,7 @@ mod tests { Null, List(vec![String("foo\nbar".to_string()), Number(3.5)])]); - assert_eq!(long_test_list.to_str().into_string(), + assert_eq!(long_test_list.to_string().into_string(), "[false,null,[\"foo\\nbar\",3.5]]".to_string()); assert_eq!( long_test_list.to_pretty_str().into_string(), @@ -2286,13 +2286,13 @@ mod tests { #[test] fn test_write_object() { - assert_eq!(mk_object([]).to_str().into_string(), "{}".to_string()); + assert_eq!(mk_object([]).to_string().into_string(), "{}".to_string()); assert_eq!(mk_object([]).to_pretty_str().into_string(), "{}".to_string()); assert_eq!( mk_object([ ("a".to_string(), Boolean(true)) - ]).to_str().into_string(), + ]).to_string().into_string(), "{\"a\":true}".to_string() ); assert_eq!( @@ -2311,7 +2311,7 @@ mod tests { ]); assert_eq!( - complex_obj.to_str().into_string(), + complex_obj.to_string().into_string(), "{\ \"b\":[\ {\"c\":\"\\f\\r\"},\ @@ -2344,7 +2344,7 @@ mod tests { // We can't compare the strings directly because the object fields be // printed in a different order. - assert_eq!(a.clone(), from_str(a.to_str().as_slice()).unwrap()); + assert_eq!(a.clone(), from_str(a.to_string().as_slice()).unwrap()); assert_eq!(a.clone(), from_str(a.to_pretty_str().as_slice()).unwrap()); } |
