Skip to content

Commit

Permalink
Change unsafe functions to safe functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sammykim committed May 16, 2013
1 parent c18e44b commit f097f43
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/libcore/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2546,23 +2546,29 @@ pub mod raw {
* would also make any pointers to it invalid.
*/
#[inline(always)]
pub unsafe fn to_ptr<T>(v: &[T]) -> *T {
let repr: **SliceRepr = transmute(&v);
transmute(&((**repr).data))
pub fn to_ptr<T>(v: &[T]) -> *T {
unsafe {
let repr: **SliceRepr = transmute(&v);
transmute(&((**repr).data))
}
}

/** see `to_ptr()` */
#[inline(always)]
pub unsafe fn to_const_ptr<T>(v: &const [T]) -> *const T {
let repr: **SliceRepr = transmute(&v);
transmute(&((**repr).data))
pub fn to_const_ptr<T>(v: &const [T]) -> *const T {
unsafe {
let repr: **SliceRepr = transmute(&v);
transmute(&((**repr).data))
}
}

/** see `to_ptr()` */
#[inline(always)]
pub unsafe fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
let repr: **SliceRepr = transmute(&v);
transmute(&((**repr).data))
pub fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
unsafe {
let repr: **SliceRepr = transmute(&v);
transmute(&((**repr).data))
}
}

/**
Expand Down

0 comments on commit f097f43

Please sign in to comment.