File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,18 @@ impl<A> Clone for OwnedRepr<A>
8686impl < A > Drop for OwnedRepr < A > {
8787 fn drop ( & mut self ) {
8888 if self . capacity > 0 {
89+ // correct because: If the elements don't need dropping, an
90+ // empty Vec is ok. Only the Vec's allocation needs dropping.
91+ //
92+ // implemented because: in some places in ndarray
93+ // where A: Copy (hence does not need drop) we use uninitialized elements in
94+ // vectors. Setting the length to 0 avoids that the vector tries to
95+ // drop, slice or otherwise produce values of these elements.
96+ // (The details of the validity letting this happen with nonzero len, are
97+ // under discussion as of this writing.)
98+ if !mem:: needs_drop :: < A > ( ) {
99+ self . len = 0 ;
100+ }
89101 // drop as a Vec.
90102 self . take_as_vec ( ) ;
91103 }
You can’t perform that action at this time.
0 commit comments