We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1fed7c2 + 0ceaf42 commit ea0b69eCopy full SHA for ea0b69e
src/data_repr.rs
@@ -86,6 +86,18 @@ impl<A> Clone for OwnedRepr<A>
86
impl<A> Drop for OwnedRepr<A> {
87
fn drop(&mut self) {
88
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
+ }
101
// drop as a Vec.
102
self.take_as_vec();
103
}
0 commit comments