pub trait ArrayStringCompare<N: Alphanumeric>{
// 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§
Sourcefn equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
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));
§Errors
may returns ArrayError
Sourcefn not_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
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));
§Errors
may returns ArrayError
Sourcefn greater_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
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));
§Errors
may returns ArrayError
Sourcefn less_equal(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
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));
§Errors
may returns ArrayError
Sourcefn greater(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
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));
§Errors
may returns ArrayError
Sourcefn less(&self, other: &Array<N>) -> Result<Array<bool>, ArrayError>
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));
§Errors
may returns ArrayError
Sourcefn compare(
&self,
other: &Array<N>,
cmp_op: impl CompareOpType,
) -> Result<Array<bool>, ArrayError>
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 withcmp_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, "<"));
§Errors
may returns ArrayError
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.