polars_arrow/compute/
bitwise.rsuse std::ops::{BitAnd, BitOr, BitXor, Not};
use crate::array::PrimitiveArray;
use crate::compute::arity::{binary, unary};
use crate::types::NativeType;
pub fn or<T>(lhs: &PrimitiveArray<T>, rhs: &PrimitiveArray<T>) -> PrimitiveArray<T>
where
T: NativeType + BitOr<Output = T>,
{
binary(lhs, rhs, lhs.dtype().clone(), |a, b| a | b)
}
pub fn xor<T>(lhs: &PrimitiveArray<T>, rhs: &PrimitiveArray<T>) -> PrimitiveArray<T>
where
T: NativeType + BitXor<Output = T>,
{
binary(lhs, rhs, lhs.dtype().clone(), |a, b| a ^ b)
}
pub fn and<T>(lhs: &PrimitiveArray<T>, rhs: &PrimitiveArray<T>) -> PrimitiveArray<T>
where
T: NativeType + BitAnd<Output = T>,
{
binary(lhs, rhs, lhs.dtype().clone(), |a, b| a & b)
}
pub fn not<T>(array: &PrimitiveArray<T>) -> PrimitiveArray<T>
where
T: NativeType + Not<Output = T>,
{
let op = move |a: T| !a;
unary(array, op, array.dtype().clone())
}
pub fn or_scalar<T>(lhs: &PrimitiveArray<T>, rhs: &T) -> PrimitiveArray<T>
where
T: NativeType + BitOr<Output = T>,
{
unary(lhs, |a| a | *rhs, lhs.dtype().clone())
}
pub fn xor_scalar<T>(lhs: &PrimitiveArray<T>, rhs: &T) -> PrimitiveArray<T>
where
T: NativeType + BitXor<Output = T>,
{
unary(lhs, |a| a ^ *rhs, lhs.dtype().clone())
}
pub fn and_scalar<T>(lhs: &PrimitiveArray<T>, rhs: &T) -> PrimitiveArray<T>
where
T: NativeType + BitAnd<Output = T>,
{
unary(lhs, |a| a & *rhs, lhs.dtype().clone())
}