extendr_api::prelude

Trait ScalarOperand

Source
pub trait ScalarOperand: 'static + Clone { }
Expand description

Elements that can be used as direct operands in arithmetic with arrays.

For example, f64 is a ScalarOperand which means that for an array a, arithmetic like a + 1.0, and, a * 2., and a += 3. are allowed.

In the description below, let A be an array or array view, let B be an array with owned data, and let C be an array with mutable data.

ScalarOperand determines for which scalars K operations &A @ K, and B @ K, and C @= K are defined, as right hand side operands, for applicable arithmetic operators (denoted @).

Left hand side scalar operands are not related to this trait (they need one impl per concrete scalar type); but they are still implemented for the same types, allowing operations K @ &A, and K @ B for primitive numeric types K.

This trait does not limit which elements can be stored in an array in general. Non-ScalarOperand types can still participate in arithmetic as array elements in in array-array operations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ScalarOperand for bool

Source§

impl ScalarOperand for f32

Source§

impl ScalarOperand for f64

Source§

impl ScalarOperand for i8

Source§

impl ScalarOperand for i16

Source§

impl ScalarOperand for i32

Source§

impl ScalarOperand for i64

Source§

impl ScalarOperand for i128

Source§

impl ScalarOperand for isize

Source§

impl ScalarOperand for u8

Source§

impl ScalarOperand for u16

Source§

impl ScalarOperand for u32

Source§

impl ScalarOperand for u64

Source§

impl ScalarOperand for u128

Source§

impl ScalarOperand for usize

Source§

impl ScalarOperand for Complex<f32>

Source§

impl ScalarOperand for Complex<f64>

Implementors§