Skip to content

Commit 3755711

Browse files
committed
collections: impl AsRef<[u8]> for String
1 parent 3a80b22 commit 3755711

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libcollections/string.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,14 @@ impl AsRef<str> for String {
10571057
}
10581058
}
10591059

1060+
#[stable(feature = "rust1", since = "1.1.0")]
1061+
impl AsRef<[u8]> for String {
1062+
#[inline]
1063+
fn as_ref(&self) -> &[u8] {
1064+
self.as_bytes()
1065+
}
1066+
}
1067+
10601068
#[stable(feature = "rust1", since = "1.0.0")]
10611069
impl<'a> From<&'a str> for String {
10621070
#[cfg(not(test))]

0 commit comments

Comments
 (0)