3 releases (1 stable)
new 1.0.0 | Apr 1, 2025 |
---|---|
0.5.0 |
|
0.4.0 |
|
0.3.0 | Apr 1, 2025 |
0.2.3 |
|
#67 in #version
136 downloads per month
12KB
125 lines
what-version
(
)
Determines the highest semver version from a list of versions that satisfies all given version requirements.
Usage
-
Add the library to your
Cargo.toml
:cargo add what-version-core
-
Call the
what_version()
function with a list of versions and version requirements.let versions = vec![ Version::parse("1.0.0").unwrap(), Version::parse("1.1.0").unwrap(), Version::parse("1.2.3").unwrap(), Version::parse("1.6.0").unwrap(), Version::parse("2.0.0").unwrap(), ]; let requirements = vec![ VersionReq::parse(">=1.1.0").unwrap(), VersionReq::parse("<2.0.0").unwrap(), ] .into_iter() .collect::<HashSet<_>>(); match what_version(requirements, versions) { Ok(chosen_version) => println!("Chosen Version: {}", chosen_version), Err(_) => eprintln!("No valid version found"), }
Dependencies
~1.8–2.9MB
~54K SLoC