Struct version_compare::VersionCompare [] [src]

pub struct VersionCompare {}

Version compare structure.

Methods

impl VersionCompare
[src]

Version compare implementation.

Compare two version number strings to each other. This compares version a to version b, and returns whether version a is greater, less or equal to version b.

The two given version numbers must be valid, or an error will be returned.

One of the following ok results may be returned: - CompOp::Eq - CompOp::Lt - CompOp::Gt

Examples

use version_compare::VersionCompare;
use version_compare::comp_op::CompOp;

// Compare version numbers
assert_eq!(VersionCompare::compare("1.2.3", "1.2.3"), Ok(CompOp::Eq));
assert_eq!(VersionCompare::compare("1.2.3", "1.2.4"), Ok(CompOp::Lt));
assert_eq!(VersionCompare::compare("1", "0.1"), Ok(CompOp::Gt));

Compare two version number strings to each other and check whether the given comparison operator is valid.

The two given version numbers must be valid, or an error will be returned.

Examples

use version_compare::VersionCompare;
use version_compare::comp_op::CompOp;

// Compare version numbers
assert!(VersionCompare::compare_to("1.2.3", "1.2.3", &CompOp::Eq).unwrap());
assert!(VersionCompare::compare_to("1.2.3", "1.2.3", &CompOp::Le).unwrap());
assert!(VersionCompare::compare_to("1.2.3", "1.2.4", &CompOp::Lt).unwrap());
assert!(VersionCompare::compare_to("1", "0.1", &CompOp::Gt).unwrap());
assert!(VersionCompare::compare_to("1", "0.1", &CompOp::Ge).unwrap());