use std::cmp;
fn compare(v1: &str, v2: &str) -> i32 {
let curr_tab = v1.split('.').collect::<Vec<_>>();
let other_tab = v2.split('.').collect::<Vec<_>>();
for i in 0..cmp::max(curr_tab.len(), other_tab.len()) {
let mut curr_int = 0i32;
let mut other_int = 0i32;
if curr_tab.len() > i {
curr_int = curr_tab[i].parse().unwrap();
}
if other_tab.len() > i {
other_int = other_tab[i].parse().unwrap();
}
if curr_int > other_int {
return 1;
}
if other_int > curr_int {
return -1;
}
}
0
}
pub fn less_than(v: &str, other: &str) -> bool {
compare(v, other) == -1
}
pub fn less_than_or_equal_to(v: &str, other: &str) -> bool {
compare(v, other) <= 0
}
pub fn greater_than(v: &str, other: &str) -> bool {
compare(v, other) == 1
}
pub fn greater_than_or_equal_to(v: &str, other: &str) -> bool {
compare(v, other) >= 0
}
pub fn equal(v: &str, other: &str) -> bool {
compare(v, other) == 0
}