Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-core/src/chunked_array/drop.rs
6940 views
1
use crate::chunked_array::object::extension::drop::drop_list;
2
use crate::prelude::*;
3
4
#[inline(never)]
5
#[cold]
6
fn drop_slow<T: PolarsDataType>(ca: &mut ChunkedArray<T>) {
7
// SAFETY:
8
// guarded by the type system
9
// the transmute only convinces the type system that we are a list
10
#[allow(clippy::transmute_undefined_repr)]
11
unsafe {
12
drop_list(std::mem::transmute::<&mut ChunkedArray<T>, &ListChunked>(
13
ca,
14
))
15
}
16
}
17
18
impl<T: PolarsDataType> Drop for ChunkedArray<T> {
19
fn drop(&mut self) {
20
if matches!(self.dtype(), DataType::List(_)) {
21
drop_slow(self);
22
}
23
}
24
}
25
26