about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/str.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index f0c0595744c..c30888529be 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -1079,11 +1079,17 @@ pub mod traits {}
 pub trait Str {
     /// Work with `self` as a slice.
     fn as_slice<'a>(&'a self) -> &'a str;
+
+    /// Convert `self` into a ~str.
+    fn into_owned(self) -> ~str;
 }
 
 impl<'self> Str for &'self str {
     #[inline]
     fn as_slice<'a>(&'a self) -> &'a str { *self }
+
+    #[inline]
+    fn into_owned(self) -> ~str { self.to_owned() }
 }
 
 impl<'self> Str for ~str {
@@ -1091,6 +1097,9 @@ impl<'self> Str for ~str {
     fn as_slice<'a>(&'a self) -> &'a str {
         let s: &'a str = *self; s
     }
+
+    #[inline]
+    fn into_owned(self) -> ~str { self }
 }
 
 impl<'self> Str for @str {
@@ -1098,6 +1107,9 @@ impl<'self> Str for @str {
     fn as_slice<'a>(&'a self) -> &'a str {
         let s: &'a str = *self; s
     }
+
+    #[inline]
+    fn into_owned(self) -> ~str { self.to_owned() }
 }
 
 impl<'self> Container for &'self str {