diff --git a/src/libcore/str.rs b/src/libcore/str.rs index b3f58ce2558..cdfcbf4cd27 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -24,6 +24,7 @@ export // Reinterpretation as_bytes, + as_bytes_slice, as_buf, as_c_str, @@ -1751,6 +1752,10 @@ pure fn as_bytes(s: ~str, f: fn(~[u8]) -> T) -> T { } } +pure fn as_bytes_slice(s: &a/str) -> &a/[u8] { + unsafe { ::unsafe::reinterpret_cast(&s) } +} + /** * Work with the byte buffer of a string as a null-terminated C string. *