]> git.lizzy.rs Git - rust.git/commitdiff
impl Str for CowString
authorSean McArthur <sean.monstar@gmail.com>
Fri, 28 Nov 2014 03:21:38 +0000 (19:21 -0800)
committerSean McArthur <sean.monstar@gmail.com>
Fri, 28 Nov 2014 03:21:38 +0000 (19:21 -0800)
This implementation existed on MaybeOwned, but has been lost in the
transition to Cows. Let's put it back.

src/libcollections/str.rs

index ebd30d758f2a7bc1bd009d7b72a931caafee2bfd..c6fa1332186ec7562cd817ba0af9160653575f2e 100644 (file)
@@ -656,6 +656,13 @@ pub mod raw {
 /// A clone-on-write string
 pub type CowString<'a> = Cow<'a, String, str>;
 
+impl<'a> Str for CowString<'a> {
+    #[inline]
+    fn as_slice<'b>(&'b self) -> &'b str {
+        (**self).as_slice()
+    }
+}
+
 /*
 Section: Trait implementations
 */