Skip to content

Commit 5d412c6

Browse files
seanmonstaralexcrichton
authored andcommitted
core: impl AsRef<[u8]> for str
1 parent 7b78086 commit 5d412c6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libcore/str/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use self::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher};
2323
use char::CharExt;
2424
use clone::Clone;
2525
use cmp::{self, Eq};
26+
use convert::AsRef;
2627
use default::Default;
2728
use fmt;
2829
use iter::ExactSizeIterator;
@@ -1843,6 +1844,14 @@ impl StrExt for str {
18431844
fn parse<T: FromStr>(&self) -> Result<T, T::Err> { FromStr::from_str(self) }
18441845
}
18451846

1847+
#[stable(feature = "rust1", since = "1.0.0")]
1848+
impl AsRef<[u8]> for str {
1849+
#[inline]
1850+
fn as_ref(&self) -> &[u8] {
1851+
self.as_bytes()
1852+
}
1853+
}
1854+
18461855
/// Pluck a code point out of a UTF-8-like byte slice and return the
18471856
/// index of the next code point.
18481857
#[inline]

0 commit comments

Comments
 (0)