core: remove unnecessary unsafe blocks/functions

This commit is contained in:
Alex Crichton
2013-04-09 01:31:23 -04:00
parent 4bfa3c6663
commit d9595d1737
17 changed files with 227 additions and 243 deletions

View File

@@ -55,17 +55,13 @@ pub fn addr_of<T>(val: &T) -> *T { unsafe { rusti::addr_of(*val) } }
/// Calculate the offset from a pointer
#[inline(always)]
pub fn offset<T>(ptr: *T, count: uint) -> *T {
unsafe {
(ptr as uint + count * sys::size_of::<T>()) as *T
}
(ptr as uint + count * sys::size_of::<T>()) as *T
}
/// Calculate the offset from a const pointer
#[inline(always)]
pub fn const_offset<T>(ptr: *const T, count: uint) -> *const T {
unsafe {
(ptr as uint + count * sys::size_of::<T>()) as *T
}
(ptr as uint + count * sys::size_of::<T>()) as *T
}
/// Calculate the offset from a mut pointer