Module feature_check::version [−][src]
Expand description
Parse version strings and compare them.
The Version
struct may be used to break a version string down
into its separate components and then compare it to another one,
e.g. to decide whether a certain feature is really supported.
use std::cmp; use feature_check::version as fversion; let v1: fversion::Version = "2.1".parse()?; let v2: fversion::Version = "2.2.b2".parse()?; println!("{} {:?} {}", v1, v1.cmp(&v2), v2); println!("equal? {}", v1 == v2); println!("smaller: {}", cmp::min(&v1, &v2)); println!("larger: {}", cmp::max(&v1, &v2)); println!("v1: {}", v1); for comp in v1.iter() { println!( "- {}/{}", match comp.num { Some(value) => value.to_string(), None => "(none)".to_string(), }, comp.rest, ); } println!("v2: {}", v2); for comp in v2.into_iter() { println!( "- {}/{}", match comp.num { Some(value) => value.to_string(), None => "(none)".to_string(), }, comp.rest, ); }
Structs
Version | A version string, both in full and broken down into components. |
VersionComponent | A single version component, e.g. “3” or “b2”. |