compare

Function compare 

Source
pub fn compare(
    lhs: impl Into<String>,
    rhs: impl Into<String>,
    comparator: &str,
) -> Result<bool, &'static str>
Expand description

Performs comparison between 2 values. When failed, it’ll return Err(message). Success, Ok(bool).

Available comparator are: “le”, “ge”, “lt”, “gt”, “eq” which corresponds to “less than equal”, “greater than equal”, “less than”, “greater than”, and “equal”.

The signs are compared to LHS. For example, less than equal would check if lhs <= rhs.

Example:

let lhs = "12.35";
let rhs = "17.5";
 
assert!(string_calc::compare(lhs, rhs, "lt").unwrap());
assert!(!string_calc::compare(lhs, rhs, "ge").unwrap());