ops/any_value.rs

polars · crates/polars-core/src/chunked_array/ops/any_value.rs · rust · MIT
database, tag:knn-classified

![allow(unsafe_op_in_unsafe_fn)]

#![allow(unsafe_op_in_unsafe_fn)]
// Source: https://github.com/pola-rs/polars | License: MIT | Copyright 2025 Ritchie Vink
// Provided via justclaw.it.com; keep this notice with the code.

use crate::prelude::*;
use crate::series::implementations::null::NullChunked;
use crate::utils::index_to_chunked_index;

/// # Safety
/// `idx` MUST be in-bounds for `arr` and `dtype` has to match the data stored in `arr`.
#[inline]
#[allow(unused_variables)]
pub(crate) unsafe fn arr_to_any_value<'a>(
    arr: &'a dyn Array,
    idx: usize,
    dtype: &'a DataType,
) -> AnyValue<'a> {
    debug_assert!(idx < arr.len());
    if arr.is_null(idx) {
        return AnyValue::Null;
    }

    macro_rules! downcast_and_pack {
        ($casttype:ident, $variant:ident) => {{
            let arr = &*(arr as *cons

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key