@@ -478,41 +478,6 @@ where
478
478
}
479
479
}
480
480
481
- /// Create an array with uninitalized elements, shape `shape`.
482
- ///
483
- /// Prefer to use [`uninit()`](ArrayBase::uninit) if possible, because it is
484
- /// easier to use correctly.
485
- ///
486
- /// **Panics** if the number of elements in `shape` would overflow isize.
487
- ///
488
- /// ### Safety
489
- ///
490
- /// Accessing uninitalized values is undefined behaviour. You must overwrite *all* the elements
491
- /// in the array after it is created; for example using
492
- /// [`raw_view_mut`](ArrayBase::raw_view_mut) or other low-level element access.
493
- ///
494
- /// The contents of the array is indeterminate before initialization and it
495
- /// is an error to perform operations that use the previous values. For
496
- /// example it would not be legal to use `a += 1.;` on such an array.
497
- ///
498
- /// This constructor is limited to elements where `A: Copy` (no destructors)
499
- /// to avoid users shooting themselves too hard in the foot.
500
- ///
501
- /// (Also note that the constructors `from_shape_vec` and
502
- /// `from_shape_vec_unchecked` allow the user yet more control, in the sense
503
- /// that Arrays can be created from arbitrary vectors.)
504
- pub unsafe fn uninitialized < Sh > ( shape : Sh ) -> Self
505
- where
506
- A : Copy ,
507
- Sh : ShapeBuilder < Dim = D > ,
508
- {
509
- let shape = shape. into_shape ( ) ;
510
- let size = size_of_shape_checked_unwrap ! ( & shape. dim) ;
511
- let mut v = Vec :: with_capacity ( size) ;
512
- v. set_len ( size) ;
513
- Self :: from_shape_vec_unchecked ( shape, v)
514
- }
515
-
516
481
/// Create an array with uninitalized elements, shape `shape`.
517
482
///
518
483
/// The uninitialized elements of type `A` are represented by the type `MaybeUninit<A>`,
@@ -619,6 +584,44 @@ where
619
584
}
620
585
array
621
586
}
587
+
588
+ #[ deprecated( note = "This method is hard to use correctly. Use `uninit` instead." ,
589
+ since = "0.15.0" ) ]
590
+ /// Create an array with uninitalized elements, shape `shape`.
591
+ ///
592
+ /// Prefer to use [`uninit()`](ArrayBase::uninit) if possible, because it is
593
+ /// easier to use correctly.
594
+ ///
595
+ /// **Panics** if the number of elements in `shape` would overflow isize.
596
+ ///
597
+ /// ### Safety
598
+ ///
599
+ /// Accessing uninitalized values is undefined behaviour. You must overwrite *all* the elements
600
+ /// in the array after it is created; for example using
601
+ /// [`raw_view_mut`](ArrayBase::raw_view_mut) or other low-level element access.
602
+ ///
603
+ /// The contents of the array is indeterminate before initialization and it
604
+ /// is an error to perform operations that use the previous values. For
605
+ /// example it would not be legal to use `a += 1.;` on such an array.
606
+ ///
607
+ /// This constructor is limited to elements where `A: Copy` (no destructors)
608
+ /// to avoid users shooting themselves too hard in the foot.
609
+ ///
610
+ /// (Also note that the constructors `from_shape_vec` and
611
+ /// `from_shape_vec_unchecked` allow the user yet more control, in the sense
612
+ /// that Arrays can be created from arbitrary vectors.)
613
+ pub unsafe fn uninitialized < Sh > ( shape : Sh ) -> Self
614
+ where
615
+ A : Copy ,
616
+ Sh : ShapeBuilder < Dim = D > ,
617
+ {
618
+ let shape = shape. into_shape ( ) ;
619
+ let size = size_of_shape_checked_unwrap ! ( & shape. dim) ;
620
+ let mut v = Vec :: with_capacity ( size) ;
621
+ v. set_len ( size) ;
622
+ Self :: from_shape_vec_unchecked ( shape, v)
623
+ }
624
+
622
625
}
623
626
624
627
impl < S , A , D > ArrayBase < S , D >
0 commit comments