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
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

5 comments on commit f097f43

@bors
Copy link
Contributor

@bors bors commented on f097f43 May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from sanxiyn
at sammykim@f097f43

@bors
Copy link
Contributor

@bors bors commented on f097f43 May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging sammykim/rust/issue-6430 = f097f43 into auto

@bors
Copy link
Contributor

@bors bors commented on f097f43 May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sammykim/rust/issue-6430 = f097f43 merged ok, testing candidate = 92b7a45

@bors
Copy link
Contributor

@bors bors commented on f097f43 May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on f097f43 May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 92b7a45

Please sign in to comment.