diff options
| author | Sean McArthur <sean.monstar@gmail.com> | 2015-05-06 15:53:34 -0700 |
|---|---|---|
| committer | Sean McArthur <sean.monstar@gmail.com> | 2015-05-08 17:13:54 -0700 |
| commit | aaa3641754543d6891c872e3be6667cfbec7b741 (patch) | |
| tree | 127e50e00952f6d02681a4176e4574c595192f5b | |
| parent | e6378cbda39521fa3b9a457b5ed36ecefe37f932 (diff) | |
| download | rust-aaa3641754543d6891c872e3be6667cfbec7b741.tar.gz rust-aaa3641754543d6891c872e3be6667cfbec7b741.zip | |
core: impl AsRef<[u8]> for str
| -rw-r--r-- | src/libcore/str/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index c9bbcba31e9..c10e1443cfc 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -21,6 +21,7 @@ use self::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher}; use char::CharExt; use clone::Clone; use cmp::{self, Eq}; +use convert::AsRef; use default::Default; use fmt; use iter::ExactSizeIterator; @@ -1842,6 +1843,14 @@ impl StrExt for str { fn parse<T: FromStr>(&self) -> Result<T, T::Err> { FromStr::from_str(self) } } +#[stable(feature = "rust1", since = "1.0.0")] +impl AsRef<[u8]> for str { + #[inline] + fn as_ref(&self) -> &[u8] { + self.as_bytes() + } +} + /// Pluck a code point out of a UTF-8-like byte slice and return the /// index of the next code point. #[inline] |
