From 46ab9eb436ecf1a1f4bd5a5e6088e75fd5f7e261 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Wed, 9 Jul 2014 15:35:54 +0200 Subject: ToStr::to_str -> ToString::to_string --- src/serialization.rs | 14 +++++++------- src/show.rs | 34 +++++++++++++++++----------------- src/test/valid.rs | 4 ++-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/serialization.rs b/src/serialization.rs index 7c11fb5..deec85c 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -187,10 +187,10 @@ impl serialize::Encoder for Encoder { self.emit_value(Float(v)) } fn emit_char(&mut self, v: char) -> Result<(), Error> { - self.emit_str(v.to_str().as_slice()) + self.emit_str(v.to_string().as_slice()) } fn emit_str(&mut self, v: &str) -> Result<(), Error> { - self.emit_value(String(v.to_str())) + self.emit_value(String(v.to_string())) } fn emit_enum(&mut self, _name: &str, f: |&mut Encoder| -> Result<(), Error>) -> Result<(), Error> { @@ -245,7 +245,7 @@ impl serialize::Encoder for Encoder { f: |&mut Encoder| -> Result<(), Error>) -> Result<(), Error> { - let old = mem::replace(&mut self.state, NextKey(f_name.to_str())); + let old = mem::replace(&mut self.state, NextKey(f_name.to_string())); try!(f(self)); if self.state != Start { println!("{}", self.state); @@ -762,7 +762,7 @@ mod tests { macro_rules! map( ($($k:ident: $v:expr),*) => ({ let mut _m = HashMap::new(); - $(_m.insert(stringify!($k).to_str(), $v);)* + $(_m.insert(stringify!($k).to_string(), $v);)* _m }) ) @@ -907,7 +907,7 @@ mod tests { foo: Integer(10), bar: Integer(4) }), - set: Array(vec![String("a".to_str())]) + set: Array(vec![String("a".to_string())]) } ); assert_eq!(v, decode!(Table(encode!(v)))); @@ -962,7 +962,7 @@ mod tests { match a { Ok(..) => fail!("should not have decoded"), Err(e) => { - assert_eq!(e.to_str().as_slice(), + assert_eq!(e.to_string().as_slice(), "expected a value of type `integer`, but \ found a value of type `float` for the key `bar`"); } @@ -980,7 +980,7 @@ mod tests { match a { Ok(..) => fail!("should not have decoded"), Err(e) => { - assert_eq!(e.to_str().as_slice(), + assert_eq!(e.to_string().as_slice(), "expected a value of type `integer` for the key `bar`"); } } diff --git a/src/show.rs b/src/show.rs index cde4773..2d2d8f1 100644 --- a/src/show.rs +++ b/src/show.rs @@ -105,42 +105,42 @@ mod tests { macro_rules! map( ($($k:expr: $v:expr),*) => ({ let mut _m = HashMap::new(); - $(_m.insert($k.to_str(), $v);)* + $(_m.insert($k.to_string(), $v);)* _m }) ) #[test] fn simple_show() { - assert_eq!(String("foo".to_str()).to_str().as_slice(), + assert_eq!(String("foo".to_string()).to_string().as_slice(), "\"foo\"") - assert_eq!(Integer(10).to_str().as_slice(), + assert_eq!(Integer(10).to_string().as_slice(), "10") - assert_eq!(Float(10.0).to_str().as_slice(), + assert_eq!(Float(10.0).to_string().as_slice(), "10.0") - assert_eq!(Float(2.4).to_str().as_slice(), + assert_eq!(Float(2.4).to_string().as_slice(), "2.4") - assert_eq!(Boolean(true).to_str().as_slice(), + assert_eq!(Boolean(true).to_string().as_slice(), "true") - assert_eq!(Datetime("test".to_str()).to_str().as_slice(), + assert_eq!(Datetime("test".to_string()).to_string().as_slice(), "test") - assert_eq!(Array(vec![]).to_str().as_slice(), + assert_eq!(Array(vec![]).to_string().as_slice(), "[]") - assert_eq!(Array(vec![Integer(1), Integer(2)]).to_str().as_slice(), + assert_eq!(Array(vec![Integer(1), Integer(2)]).to_string().as_slice(), "[1, 2]") } #[test] fn table() { - assert_eq!(Table(map! { }).to_str().as_slice(), + assert_eq!(Table(map! { }).to_string().as_slice(), "") - assert_eq!(Table(map! { "test": Integer(2) }).to_str().as_slice(), + assert_eq!(Table(map! { "test": Integer(2) }).to_string().as_slice(), "test = 2\n") assert_eq!(Table(map! { "test": Integer(2), "test2": Table(map! { - "test": String("wut".to_str()) + "test": String("wut".to_string()) }) - }).to_str().as_slice(), + }).to_string().as_slice(), "test = 2\n\ \n\ [test2]\n\ @@ -148,9 +148,9 @@ mod tests { assert_eq!(Table(map! { "test": Integer(2), "test2": Table(map! { - "test": String("wut".to_str()) + "test": String("wut".to_string()) }) - }).to_str().as_slice(), + }).to_string().as_slice(), "test = 2\n\ \n\ [test2]\n\ @@ -158,9 +158,9 @@ mod tests { assert_eq!(Table(map! { "test": Integer(2), "test2": Array(vec![Table(map! { - "test": String("wut".to_str()) + "test": String("wut".to_string()) })]) - }).to_str().as_slice(), + }).to_string().as_slice(), "test = 2\n\ \n\ [[test2]]\n\ diff --git a/src/test/valid.rs b/src/test/valid.rs index bc46d1a..9a812d5 100644 --- a/src/test/valid.rs +++ b/src/test/valid.rs @@ -15,7 +15,7 @@ fn to_json(toml: Value) -> json::Json { } match toml { String(s) => doit("string", json::String(s)), - Integer(i) => doit("integer", json::String(i.to_str())), + Integer(i) => doit("integer", json::String(i.to_string())), Float(f) => doit("float", json::String({ let (bytes, _) = strconv::float_to_str_bytes_common(f, 10, true, @@ -26,7 +26,7 @@ fn to_json(toml: Value) -> json::Json { let s = String::from_utf8(bytes).unwrap(); if s.as_slice().contains(".") {s} else {format!("{}.0", s)} })), - Boolean(b) => doit("bool", json::String(b.to_str())), + Boolean(b) => doit("bool", json::String(b.to_string())), Datetime(s) => doit("datetime", json::String(s)), Array(arr) => { let is_table = match arr.as_slice().head() { -- cgit v1.2.3