Skip to main content

Numeric

Trait Numeric 

Source
pub trait Numeric: Copy + PartialOrd {
    const DTYPE: DType;
    const ZERO: Self;
    const ONE: Self;

    // Required methods
    fn into_column(values: Vec<Self>) -> Column;
    fn is_missing(self) -> bool;
    fn to_f64(self) -> f64;
    fn try_from_f64(x: f64) -> Option<Self>;
    fn wrapping_add(self, other: Self) -> Self;
    fn wrapping_sub(self, other: Self) -> Self;
    fn wrapping_mul(self, other: Self) -> Self;
    fn wrapping_abs(self) -> Self;
}
Expand description

A numeric column element type. Implemented for f64 and i64; adding i32 / f32 / u64 later is just another impl plus a dispatch arm.

Required Associated Constants§

Source

const DTYPE: DType

The column dtype backed by this element type.

Source

const ZERO: Self

Additive identity (cumsum seed).

Source

const ONE: Self

Multiplicative identity (cumprod seed).

Required Methods§

Source

fn into_column(values: Vec<Self>) -> Column

Wrap a computed buffer back into a Column of this element’s dtype.

Source

fn is_missing(self) -> bool

Whether this element is the missing sentinel (NaN for f64; never i64).

Source

fn to_f64(self) -> f64

Widen to f64 (lossless for both supported types within range).

Source

fn try_from_f64(x: f64) -> Option<Self>

Narrow from f64 losslessly, or None when the value would not fit (non-integral / out of range / NaN for i64). Powers the keep-vs-promote decision in clip / where / mask / assignment.

Source

fn wrapping_add(self, other: Self) -> Self

Wrapping add (matches pandas/numpy int64 overflow; plain + for f64).

Source

fn wrapping_sub(self, other: Self) -> Self

Wrapping subtract.

Source

fn wrapping_mul(self, other: Self) -> Self

Wrapping multiply.

Source

fn wrapping_abs(self) -> Self

Wrapping absolute value (abs(i64::MIN) == i64::MIN, like pandas).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Numeric for f32

Source§

const DTYPE: DType = DType::F32

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

fn into_column(values: Vec<Self>) -> Column

Source§

fn is_missing(self) -> bool

Source§

fn to_f64(self) -> f64

Source§

fn try_from_f64(x: f64) -> Option<Self>

Source§

fn wrapping_add(self, other: Self) -> Self

Source§

fn wrapping_sub(self, other: Self) -> Self

Source§

fn wrapping_mul(self, other: Self) -> Self

Source§

fn wrapping_abs(self) -> Self

Source§

impl Numeric for f64

Source§

const DTYPE: DType = DType::F64

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

fn into_column(values: Vec<Self>) -> Column

Source§

fn is_missing(self) -> bool

Source§

fn to_f64(self) -> f64

Source§

fn try_from_f64(x: f64) -> Option<Self>

Source§

fn wrapping_add(self, other: Self) -> Self

Source§

fn wrapping_sub(self, other: Self) -> Self

Source§

fn wrapping_mul(self, other: Self) -> Self

Source§

fn wrapping_abs(self) -> Self

Source§

impl Numeric for i32

Source§

const DTYPE: DType = DType::I32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn into_column(values: Vec<Self>) -> Column

Source§

fn is_missing(self) -> bool

Source§

fn to_f64(self) -> f64

Source§

fn try_from_f64(x: f64) -> Option<Self>

Source§

fn wrapping_add(self, other: Self) -> Self

Source§

fn wrapping_sub(self, other: Self) -> Self

Source§

fn wrapping_mul(self, other: Self) -> Self

Source§

fn wrapping_abs(self) -> Self

Source§

impl Numeric for i64

Source§

const DTYPE: DType = DType::I64

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn into_column(values: Vec<Self>) -> Column

Source§

fn is_missing(self) -> bool

Source§

fn to_f64(self) -> f64

Source§

fn try_from_f64(x: f64) -> Option<Self>

Source§

fn wrapping_add(self, other: Self) -> Self

Source§

fn wrapping_sub(self, other: Self) -> Self

Source§

fn wrapping_mul(self, other: Self) -> Self

Source§

fn wrapping_abs(self) -> Self

Implementors§