Skip to main content

BinaryScalarOp

Trait BinaryScalarOp 

Source
pub trait BinaryScalarOp<T> {
    // Required method
    fn apply(lhs: T, rhs: T) -> T;
}
Expand description

Ordinary CPU entry points that take a caller-provided destination and the caller’s own arithmetic instead of the typed pool. A binary operation between two scalars of the same type.

Implement this for a marker type in the crate that owns the operation. That is how an external scalar’s contribution supplies its own arithmetic.

§Examples

use tenferro_internal_cpu_kernels::scalar_ops::{AddOp, BinaryScalarOp};

assert_eq!(<AddOp as BinaryScalarOp<f64>>::apply(1.0, 2.0), 3.0);
// Integers wrap, so the shared path agrees with the preset path in every build.
assert_eq!(<AddOp as BinaryScalarOp<i32>>::apply(i32::MAX, 1), i32::MIN);

Required Methods§

Source

fn apply(lhs: T, rhs: T) -> T

Apply the operation.

§Examples
use tenferro_internal_cpu_kernels::scalar_ops::{BinaryScalarOp, MulOp};

assert_eq!(<MulOp as BinaryScalarOp<i64>>::apply(3, 4), 12);

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§