Function tauri::api::version::compare

source ·
pub fn compare(first: &str, second: &str) -> Result<i8>
Expand description

Compare two semver versions.

If the first semver is greater, returns -1. If the second semver is greater, returns 1. If they are equal, returns 0.

§Examples

use tauri::api::version::compare;
assert_eq!(compare("0.15.0", "0.15.5").unwrap(), 1);
assert_eq!(compare("0.15.10", "0.15.9").unwrap(), -1);
assert_eq!(compare("0.15.10", "0.16.10").unwrap(), 1);
assert_eq!(compare("1.57.0", "2.17.4").unwrap(), 1);
assert_eq!(compare("0.0.0", "0.0.0").unwrap(), 0);