We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 127144b commit 8415515Copy full SHA for 8415515
src/libcore/str.rs
@@ -1752,8 +1752,17 @@ pure fn as_bytes<T>(s: ~str, f: fn(~[u8]) -> T) -> T {
1752
}
1753
1754
1755
+/**
1756
+ * Work with the byte buffer of a string as a byte slice.
1757
+ *
1758
+ * The byte slice does not include the null terminator.
1759
+ */
1760
pure fn as_bytes_slice(s: &a/str) -> &a/[u8] {
- unsafe { ::unsafe::reinterpret_cast(&s) }
1761
+ unsafe {
1762
+ let (ptr, len): (*u8, uint) = ::unsafe::reinterpret_cast(&s);
1763
+ let outgoing_tuple: (*u8, uint) = (ptr, len - 1);
1764
+ return ::unsafe::reinterpret_cast(&outgoing_tuple);
1765
+ }
1766
1767
1768
/**
0 commit comments