From 55612bcae8e16f7ef24bb6f871ea22267b632c4c Mon Sep 17 00:00:00 2001 From: root Date: Tue, 19 May 2015 17:01:38 +0200 Subject: [PATCH] Add comment to Array::new --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index a1d5ebd..de96dcc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,6 +33,10 @@ macro_rules! fix_array_impl { ($len:expr ) => ( unsafe impl Array for [T; $len] { 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() } #[inline] fn as_ptr(&self) -> *const T { self as *const _ as *const _ }