]> git.lizzy.rs Git - rust.git/commitdiff
Rename to_str to to_string
authorSteven Fackler <sfackler@gmail.com>
Mon, 21 Jul 2014 00:12:40 +0000 (17:12 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 21 Jul 2014 16:54:52 +0000 (09:54 -0700)
Closes #15796.

[breaking-change]

src/libstd/ascii.rs
src/libstd/lib.rs
src/libstd/prelude.rs
src/libstd/task.rs
src/libstd/to_str.rs [deleted file]
src/libstd/to_string.rs [new file with mode: 0644]
src/test/run-pass/class-cast-to-trait-cross-crate-2.rs
src/test/run-pass/send_str_treemap.rs

index b9c86e2b23586b49b22ad845e677b90ba79002ea..966e4f8811eaaa12a11fa82bc82f2c82d160b1b7 100644 (file)
@@ -20,7 +20,7 @@
 use slice::{ImmutableVector, MutableVector, Vector};
 use str::{OwnedStr, Str, StrAllocating, StrSlice};
 use string::String;
-use to_str::{IntoStr};
+use to_string::IntoStr;
 use vec::Vec;
 
 /// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero.
index ad6942712ac9af3f484a3619a6e5d2d88cfcb937..e14092bc8dc1604e04b29883d24396bf480b95fa 100644 (file)
@@ -239,7 +239,7 @@ fn start(argc: int, argv: *const *const u8) -> int {
 
 pub mod from_str;
 pub mod num;
-pub mod to_str;
+pub mod to_string;
 
 /* Common data structures */
 
index eee494c7bc0a1e218808812459dedfe88569a81c..0fa223305a669d36fb929c9896d864e85768e9bd 100644 (file)
@@ -78,7 +78,7 @@
 #[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek};
 #[doc(no_inline)] pub use str::{Str, StrVector, StrSlice, OwnedStr};
 #[doc(no_inline)] pub use str::{IntoMaybeOwned, StrAllocating, UnicodeStrSlice};
-#[doc(no_inline)] pub use to_str::{ToString, IntoStr};
+#[doc(no_inline)] pub use to_string::{ToString, IntoStr};
 #[doc(no_inline)] pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
 #[doc(no_inline)] pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
 #[doc(no_inline)] pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
index 4b8c15a0152a39f2316070c172c82a578267131e..19ad81a04834d606ebaa613928f281f6bf8a220f 100644 (file)
 use str::{Str, SendStr, IntoMaybeOwned};
 use string::String;
 use sync::Future;
-use to_str::ToString;
+use to_string::ToString;
 
 /// A means of spawning a task
 pub trait Spawner {
diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs
deleted file mode 100644 (file)
index c19fd81..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/*!
-
-The `ToString` trait for converting to strings
-
-*/
-
-#![experimental]
-
-use fmt;
-use string::String;
-
-/// A generic trait for converting a value to a string
-pub trait ToString {
-    /// Converts the value of `self` to an owned string
-    fn to_string(&self) -> String;
-}
-
-/// Trait for converting a type to a string, consuming it in the process.
-pub trait IntoStr {
-    /// Consume and convert to a string.
-    fn into_string(self) -> String;
-}
-
-impl<T: fmt::Show> ToString for T {
-    fn to_string(&self) -> String {
-        format!("{}", *self)
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use super::*;
-
-    #[test]
-    fn test_simple_types() {
-        assert_eq!(1i.to_string(), "1".to_string());
-        assert_eq!((-1i).to_string(), "-1".to_string());
-        assert_eq!(200u.to_string(), "200".to_string());
-        assert_eq!(2u8.to_string(), "2".to_string());
-        assert_eq!(true.to_string(), "true".to_string());
-        assert_eq!(false.to_string(), "false".to_string());
-        assert_eq!(().to_string(), "()".to_string());
-        assert_eq!(("hi".to_string()).to_string(), "hi".to_string());
-    }
-
-    #[test]
-    fn test_vectors() {
-        let x: Vec<int> = vec![];
-        assert_eq!(x.to_string(), "[]".to_string());
-        assert_eq!((vec![1i]).to_string(), "[1]".to_string());
-        assert_eq!((vec![1i, 2, 3]).to_string(), "[1, 2, 3]".to_string());
-        assert!((vec![vec![], vec![1i], vec![1i, 1]]).to_string() ==
-               "[[], [1], [1, 1]]".to_string());
-    }
-}
diff --git a/src/libstd/to_string.rs b/src/libstd/to_string.rs
new file mode 100644 (file)
index 0000000..c19fd81
--- /dev/null
@@ -0,0 +1,66 @@
+// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+/*!
+
+The `ToString` trait for converting to strings
+
+*/
+
+#![experimental]
+
+use fmt;
+use string::String;
+
+/// A generic trait for converting a value to a string
+pub trait ToString {
+    /// Converts the value of `self` to an owned string
+    fn to_string(&self) -> String;
+}
+
+/// Trait for converting a type to a string, consuming it in the process.
+pub trait IntoStr {
+    /// Consume and convert to a string.
+    fn into_string(self) -> String;
+}
+
+impl<T: fmt::Show> ToString for T {
+    fn to_string(&self) -> String {
+        format!("{}", *self)
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use prelude::*;
+    use super::*;
+
+    #[test]
+    fn test_simple_types() {
+        assert_eq!(1i.to_string(), "1".to_string());
+        assert_eq!((-1i).to_string(), "-1".to_string());
+        assert_eq!(200u.to_string(), "200".to_string());
+        assert_eq!(2u8.to_string(), "2".to_string());
+        assert_eq!(true.to_string(), "true".to_string());
+        assert_eq!(false.to_string(), "false".to_string());
+        assert_eq!(().to_string(), "()".to_string());
+        assert_eq!(("hi".to_string()).to_string(), "hi".to_string());
+    }
+
+    #[test]
+    fn test_vectors() {
+        let x: Vec<int> = vec![];
+        assert_eq!(x.to_string(), "[]".to_string());
+        assert_eq!((vec![1i]).to_string(), "[1]".to_string());
+        assert_eq!((vec![1i, 2, 3]).to_string(), "[1, 2, 3]".to_string());
+        assert!((vec![vec![], vec![1i], vec![1i, 1]]).to_string() ==
+               "[[], [1], [1, 1]]".to_string());
+    }
+}
index e3dbaa62d353264ed5eb1b40e6bf0e49581a1f1f..a2ae91abd131a170eda6d5f1a3eeabaa550fb0fe 100644 (file)
@@ -11,7 +11,7 @@
 // aux-build:cci_class_cast.rs
 extern crate cci_class_cast;
 
-use std::to_str::ToString;
+use std::to_string::ToString;
 use cci_class_cast::kitty::cat;
 
 fn print_out(thing: Box<ToString>, expected: String) {
index f3a730aa2b39589b823994ebd3c6ab321ff183f7..e51c94428dae3095979f0836c0d484d1d05be7d4 100644 (file)
@@ -12,7 +12,7 @@
 
 use std::collections::{ Map, MutableMap};
 use std::str::{SendStr, Owned, Slice};
-use std::to_str::ToString;
+use std::to_string::ToString;
 use self::collections::TreeMap;
 use std::option::Some;