Stabilize ptr_unaligned feature, closes #37955
This commit is contained in:
committed by
Alex Crichton
parent
65b7c4ed31
commit
d38ea8b371
@@ -161,8 +161,6 @@ pub unsafe fn read<T>(src: *const T) -> T {
|
|||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(ptr_unaligned)]
|
|
||||||
///
|
|
||||||
/// let x = 12;
|
/// let x = 12;
|
||||||
/// let y = &x as *const i32;
|
/// let y = &x as *const i32;
|
||||||
///
|
///
|
||||||
@@ -171,7 +169,7 @@ pub unsafe fn read<T>(src: *const T) -> T {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[unstable(feature = "ptr_unaligned", issue = "37955")]
|
#[stable(feature = "ptr_unaligned", since = "1.17.0")]
|
||||||
pub unsafe fn read_unaligned<T>(src: *const T) -> T {
|
pub unsafe fn read_unaligned<T>(src: *const T) -> T {
|
||||||
let mut tmp: T = mem::uninitialized();
|
let mut tmp: T = mem::uninitialized();
|
||||||
copy_nonoverlapping(src as *const u8,
|
copy_nonoverlapping(src as *const u8,
|
||||||
@@ -243,8 +241,6 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
|
|||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(ptr_unaligned)]
|
|
||||||
///
|
|
||||||
/// let mut x = 0;
|
/// let mut x = 0;
|
||||||
/// let y = &mut x as *mut i32;
|
/// let y = &mut x as *mut i32;
|
||||||
/// let z = 12;
|
/// let z = 12;
|
||||||
@@ -255,7 +251,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "ptr_unaligned", issue = "37955")]
|
#[stable(feature = "ptr_unaligned", since = "1.17.0")]
|
||||||
pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
|
pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
|
||||||
copy_nonoverlapping(&src as *const T as *const u8,
|
copy_nonoverlapping(&src as *const T as *const u8,
|
||||||
dst as *mut u8,
|
dst as *mut u8,
|
||||||
|
|||||||
Reference in New Issue
Block a user