diff options
| -rw-r--r-- | src/libcore/vec.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 5f450ec8e34..2eaaaf6751e 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1420,6 +1420,11 @@ mod unsafe { data: u8 }; + type slice_repr = { + mut data: *u8, + mut len: uint + }; + /** * Constructs a vector from an unsafe pointer to a buffer * @@ -1465,6 +1470,13 @@ mod unsafe { } + #[inline(always)] + unsafe fn to_ptr_slice<T>(v: &[const T]) -> *T { + let repr: **slice_repr = ::unsafe::reinterpret_cast(addr_of(v)); + ret ::unsafe::reinterpret_cast(addr_of((**repr).data)); + } + + /** * Form a slice from a pointer and length (as a number of units, * not bytes). |
