Add comment to Array::new

This commit is contained in:
root
2015-05-19 17:01:38 +02:00
parent 04b9af476b
commit 55612bcae8
+4
View File
@@ -33,6 +33,10 @@ macro_rules! fix_array_impl {
($len:expr ) => ( ($len:expr ) => (
unsafe impl<T> Array for [T; $len] { unsafe impl<T> Array for [T; $len] {
type Item = T; type Item = T;
/// Note: Returnin an uninitialized value here only works
/// if we can be sure the data is never used. The nullable pointer
/// inside enum optimization conflicts with this this for example,
/// so we need to be extra careful. See `Flag` enum.
unsafe fn new() -> [T; $len] { mem::uninitialized() } unsafe fn new() -> [T; $len] { mem::uninitialized() }
#[inline] #[inline]
fn as_ptr(&self) -> *const T { self as *const _ as *const _ } fn as_ptr(&self) -> *const T { self as *const _ as *const _ }