]> git.lizzy.rs Git - rust.git/commitdiff
Implement DeepClone for str types.
authorChris Morgan <me@chrismorgan.info>
Fri, 16 Aug 2013 10:17:02 +0000 (20:17 +1000)
committerChris Morgan <me@chrismorgan.info>
Fri, 16 Aug 2013 10:17:02 +0000 (20:17 +1000)
src/libstd/str.rs

index a759b8cbd62355ec530eabf74bf62bce8dffe65d..88345effc019974d16c151986b459b437d1c84c4 100644 (file)
@@ -20,7 +20,7 @@
 use cast;
 use char;
 use char::Char;
-use clone::Clone;
+use clone::{Clone, DeepClone};
 use container::{Container, Mutable};
 use iter::Times;
 use iterator::{Iterator, FromIterator, Extendable};
@@ -2104,6 +2104,13 @@ fn clone(&self) -> ~str {
     }
 }
 
+impl DeepClone for ~str {
+    #[inline]
+    fn deep_clone(&self) -> ~str {
+        self.to_owned()
+    }
+}
+
 impl Clone for @str {
     #[inline]
     fn clone(&self) -> @str {
@@ -2111,6 +2118,13 @@ fn clone(&self) -> @str {
     }
 }
 
+impl DeepClone for @str {
+    #[inline]
+    fn deep_clone(&self) -> @str {
+        *self
+    }
+}
+
 impl FromIterator<char> for ~str {
     #[inline]
     fn from_iterator<T: Iterator<char>>(iterator: &mut T) -> ~str {