about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcollections/string.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index 3c668f7fe9b..52d72501b4a 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -1058,6 +1058,14 @@ impl AsRef<str> for String {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+impl AsRef<[u8]> for String {
+    #[inline]
+    fn as_ref(&self) -> &[u8] {
+        self.as_bytes()
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
 impl<'a> From<&'a str> for String {
     #[cfg(not(test))]
     #[inline]