Path: blob/main/crates/polars-core/src/chunked_array/drop.rs
6940 views
use crate::chunked_array::object::extension::drop::drop_list;1use crate::prelude::*;23#[inline(never)]4#[cold]5fn drop_slow<T: PolarsDataType>(ca: &mut ChunkedArray<T>) {6// SAFETY:7// guarded by the type system8// the transmute only convinces the type system that we are a list9#[allow(clippy::transmute_undefined_repr)]10unsafe {11drop_list(std::mem::transmute::<&mut ChunkedArray<T>, &ListChunked>(12ca,13))14}15}1617impl<T: PolarsDataType> Drop for ChunkedArray<T> {18fn drop(&mut self) {19if matches!(self.dtype(), DataType::List(_)) {20drop_slow(self);21}22}23}242526