From 093ebd5a62d77678046b5e56420d46df37a97129 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 6 May 2015 15:53:53 -0700 Subject: [PATCH] collections: impl AsRef<[u8]> for String --- src/libcollections/string.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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 @@ -1057,6 +1057,14 @@ impl AsRef 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))]