pub trait ArrayStringCompare<N: Alphanumeric>where
    Self: Sized + Clone,{
    // Required methods
    fn equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
    fn not_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
    fn greater_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
    fn less_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
    fn greater(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
    fn less(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>;
    fn compare(
        &self,
        other: &Array<N>,
        cmp_op: impl CompareOpType
    ) -> Result<Array<bool>, ArrayError>;
}
Expand description

ArrayTrait - Alphanumeric Array operations

Required Methods§

source

fn equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

Return (self == other) element-wise

Arguments
  • other - array to perform the operation with
Examples
use arr_rs::prelude::*;

let expected = Array::flat(vec![true, false]);
let arr = Array::flat(vec!["aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.equal(&other));
source

fn not_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

Return (self != other) element-wise

Arguments
  • other - array to perform the operation with
Examples
use arr_rs::prelude::*;

let expected = Array::flat(vec![false, true]);
let arr = Array::flat(vec!["aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.not_equal(&other));
source

fn greater_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

Return (self >= other) element-wise

Arguments
  • other - array to perform the operation with
Examples
use arr_rs::prelude::*;

let expected = Array::flat(vec![true, false, true]);
let arr = Array::flat(vec!["aaa".to_string(), "aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "aba".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.greater_equal(&other));
source

fn less_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

Return (self <= other) element-wise

Arguments
  • other - array to perform the operation with
Examples
use arr_rs::prelude::*;

let expected = Array::flat(vec![true, true, false]);
let arr = Array::flat(vec!["aaa".to_string(), "aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "aba".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.less_equal(&other));
source

fn greater(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

Return (self > other) element-wise

Arguments
  • other - array to perform the operation with
Examples
use arr_rs::prelude::*;

let expected = Array::flat(vec![false, false, true]);
let arr = Array::flat(vec!["aaa".to_string(), "aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "aba".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.greater(&other));
source

fn less(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

Return (self < other) element-wise

Arguments
  • other - array to perform the operation with
Examples
use arr_rs::prelude::*;

let expected = Array::flat(vec![false, true, false]);
let arr = Array::flat(vec!["aaa".to_string(), "aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "aba".to_string(), "bbbbb".to_string()]).unwrap();
assert_eq!(expected, arr.less(&other));
source

fn compare( &self, other: &Array<N>, cmp_op: impl CompareOpType ) -> Result<Array<bool>, ArrayError>

Performs element-wise comparison of two string arrays using the comparison operator specified by cmp_op

Arguments
  • other - array to perform the operation with
  • cmp_op - Type of comparison: {“<”, “<=”, “==”, “>=”, “>”, “!=”}
Examples
use arr_rs::prelude::*;

let arr = Array::flat(vec!["aaa".to_string(), "bbbxx".to_string()]);
let other = Array::flat(vec!["aaa".to_string(), "bbbbb".to_string()]).unwrap();

let expected = Array::flat(vec![true, false]);
assert_eq!(expected, arr.compare(&other, "=="));

let expected = Array::flat(vec![false, true]);
assert_eq!(expected, arr.compare(&other, "!="));

let expected = Array::flat(vec![true, true]);
assert_eq!(expected, arr.compare(&other, ">="));

let expected = Array::flat(vec![true, false]);
assert_eq!(expected, arr.compare(&other, "<="));

let expected = Array::flat(vec![false, true]);
assert_eq!(expected, arr.compare(&other, ">"));

let expected = Array::flat(vec![false, false]);
assert_eq!(expected, arr.compare(&other, "<"));

Implementations on Foreign Types§

source§

impl<N: Alphanumeric> ArrayStringCompare<N> for Result<Array<N>, ArrayError>

source§

fn equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

source§

fn not_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

source§

fn greater_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

source§

fn less_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

source§

fn greater(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

source§

fn less(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>

source§

fn compare( &self, other: &Array<N>, cmp_op: impl CompareOpType ) -> Result<Array<bool>, ArrayError>

Implementors§