Skip to content

Commit

Permalink
core: impl AsRef<[u8]> for str
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed May 9, 2015
1 parent e6378cb commit aaa3641
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/libcore/str/mod.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit aaa3641

Please sign in to comment.