Skip to content

Commit 6fc3f24

Browse files
committed
Remove deprecated uninitialized and maybe_uninit
Replaced by Array::uninit already in 0.15.x
1 parent 45009ff commit 6fc3f24

File tree

2 files changed

+0
-90
lines changed

2 files changed

+0
-90
lines changed

src/impl_constructors.rs

-62
Original file line numberDiff line numberDiff line change
@@ -625,66 +625,4 @@ where
625625
}
626626
array
627627
}
628-
629-
#[deprecated(
630-
note = "This method is hard to use correctly. Use `uninit` instead.",
631-
since = "0.15.0"
632-
)]
633-
#[allow(clippy::uninit_vec)] // this is explicitly intended to create uninitialized memory
634-
/// Create an array with uninitialized elements, shape `shape`.
635-
///
636-
/// Prefer to use [`uninit()`](ArrayBase::uninit) if possible, because it is
637-
/// easier to use correctly.
638-
///
639-
/// **Panics** if the number of elements in `shape` would overflow isize.
640-
///
641-
/// ### Safety
642-
///
643-
/// Accessing uninitialized values is undefined behaviour. You must overwrite *all* the elements
644-
/// in the array after it is created; for example using
645-
/// [`raw_view_mut`](ArrayBase::raw_view_mut) or other low-level element access.
646-
///
647-
/// The contents of the array is indeterminate before initialization and it
648-
/// is an error to perform operations that use the previous values. For
649-
/// example it would not be legal to use `a += 1.;` on such an array.
650-
///
651-
/// This constructor is limited to elements where `A: Copy` (no destructors)
652-
/// to avoid users shooting themselves too hard in the foot.
653-
///
654-
/// (Also note that the constructors `from_shape_vec` and
655-
/// `from_shape_vec_unchecked` allow the user yet more control, in the sense
656-
/// that Arrays can be created from arbitrary vectors.)
657-
pub unsafe fn uninitialized<Sh>(shape: Sh) -> Self
658-
where
659-
A: Copy,
660-
Sh: ShapeBuilder<Dim = D>,
661-
{
662-
let shape = shape.into_shape_with_order();
663-
let size = size_of_shape_checked_unwrap!(&shape.dim);
664-
let mut v = Vec::with_capacity(size);
665-
v.set_len(size);
666-
Self::from_shape_vec_unchecked(shape, v)
667-
}
668-
}
669-
670-
impl<S, A, D> ArrayBase<S, D>
671-
where
672-
S: DataOwned<Elem = MaybeUninit<A>>,
673-
D: Dimension,
674-
{
675-
/// Create an array with uninitialized elements, shape `shape`.
676-
///
677-
/// This method has been renamed to `uninit`
678-
#[deprecated(note = "Renamed to `uninit`", since = "0.15.0")]
679-
pub fn maybe_uninit<Sh>(shape: Sh) -> Self
680-
where Sh: ShapeBuilder<Dim = D>
681-
{
682-
unsafe {
683-
let shape = shape.into_shape_with_order();
684-
let size = size_of_shape_checked_unwrap!(&shape.dim);
685-
let mut v = Vec::with_capacity(size);
686-
v.set_len(size);
687-
Self::from_shape_vec_unchecked(shape, v)
688-
}
689-
}
690628
}

tests/array-construct.rs

-28
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,6 @@ fn test_arcarray_thread_safe()
5050
is_sync(&a);
5151
}
5252

53-
#[test]
54-
#[cfg(feature = "std")]
55-
#[allow(deprecated)] // uninitialized
56-
fn test_uninit()
57-
{
58-
unsafe {
59-
let mut a = Array::<f32, _>::uninitialized((3, 4).f());
60-
assert_eq!(a.dim(), (3, 4));
61-
assert_eq!(a.strides(), &[1, 3]);
62-
let b = Array::<f32, _>::linspace(0., 25., a.len())
63-
.into_shape_with_order(a.dim())
64-
.unwrap();
65-
a.assign(&b);
66-
assert_eq!(&a, &b);
67-
assert_eq!(a.t(), b.t());
68-
}
69-
}
70-
7153
#[test]
7254
fn test_from_fn_c0()
7355
{
@@ -249,16 +231,6 @@ fn deny_wraparound_from_shape_fn()
249231
let _five_large = Array::<f32, _>::from_shape_fn((3, 7, 29, 36760123, 823996703), |_| 0.);
250232
}
251233

252-
#[should_panic]
253-
#[test]
254-
#[allow(deprecated)] // uninitialized
255-
fn deny_wraparound_uninitialized()
256-
{
257-
unsafe {
258-
let _five_large = Array::<f32, _>::uninitialized((3, 7, 29, 36760123, 823996703));
259-
}
260-
}
261-
262234
#[should_panic]
263235
#[test]
264236
fn deny_wraparound_uninit()

0 commit comments

Comments
 (0)