Move IntoString to collections::string

This commit is contained in:
Brendan Zabarauskas 2014-11-15 23:57:54 +11:00
parent 2d8ca045d6
commit 59abf75d9e
4 changed files with 9 additions and 10 deletions

View File

@ -802,6 +802,12 @@ fn from_str(s: &str) -> Option<String> {
}
}
/// Trait for converting a type to a string, consuming it in the process.
pub trait IntoString {
/// Consume and convert to a string.
fn into_string(self) -> String;
}
/// Unsafe operations
#[unstable = "waiting on raw module conventions"]
pub mod raw {

View File

@ -21,8 +21,7 @@
use option::{Option, Some, None};
use slice::{SlicePrelude, AsSlice};
use str::{Str, StrPrelude};
use string::{mod, String};
use to_string::IntoString;
use string::{mod, String, IntoString};
use vec::Vec;
/// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero.

View File

@ -76,14 +76,14 @@
#[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek};
#[doc(no_inline)] pub use str::{Str, StrVector, StrPrelude};
#[doc(no_inline)] pub use str::{IntoMaybeOwned, StrAllocating, UnicodeStrPrelude};
#[doc(no_inline)] pub use to_string::{ToString, IntoString};
#[doc(no_inline)] pub use to_string::ToString;
#[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};
#[doc(no_inline)] pub use slice::{SlicePrelude, AsSlice, CloneSlicePrelude};
#[doc(no_inline)] pub use slice::{VectorVector, PartialEqSlicePrelude, OrdSlicePrelude};
#[doc(no_inline)] pub use slice::{CloneSliceAllocPrelude, OrdSliceAllocPrelude, SliceAllocPrelude};
#[doc(no_inline)] pub use string::String;
#[doc(no_inline)] pub use string::{IntoString, String};
#[doc(no_inline)] pub use vec::Vec;
// Reexported runtime types

View File

@ -25,12 +25,6 @@ pub trait ToString {
fn to_string(&self) -> String;
}
/// Trait for converting a type to a string, consuming it in the process.
pub trait IntoString {
/// 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)