diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 5f450ec8e34d7aa7887e2150d2e11b9f2864fe7e..2eaaaf6751eac7ea058f78d36a41a5fd62d57783 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 @@ unsafe fn to_ptr(v: ~[const T]) -> *T { } + #[inline(always)] + unsafe fn to_ptr_slice(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).