From f097f4309edac03f362bd9690560600b5e0d7d26 Mon Sep 17 00:00:00 2001 From: Sangeun Kim Date: Thu, 16 May 2013 13:34:32 +0900 Subject: [PATCH] Change unsafe functions to safe functions --- src/libcore/vec.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 0fb697b686fb3..9db3585e03a5f 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -2546,23 +2546,29 @@ pub mod raw { * would also make any pointers to it invalid. */ #[inline(always)] - pub unsafe fn to_ptr(v: &[T]) -> *T { - let repr: **SliceRepr = transmute(&v); - transmute(&((**repr).data)) + pub fn to_ptr(v: &[T]) -> *T { + unsafe { + let repr: **SliceRepr = transmute(&v); + transmute(&((**repr).data)) + } } /** see `to_ptr()` */ #[inline(always)] - pub unsafe fn to_const_ptr(v: &const [T]) -> *const T { - let repr: **SliceRepr = transmute(&v); - transmute(&((**repr).data)) + pub fn to_const_ptr(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(v: &mut [T]) -> *mut T { - let repr: **SliceRepr = transmute(&v); - transmute(&((**repr).data)) + pub fn to_mut_ptr(v: &mut [T]) -> *mut T { + unsafe { + let repr: **SliceRepr = transmute(&v); + transmute(&((**repr).data)) + } } /**