File: minimal.rs

package info (click to toggle)
rust-version-compare 0.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: makefile: 4
file content (19 lines) | stat: -rw-r--r-- 570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//! A minimal usage example of the version-compare crate.
//!
//! This compares two given version number strings, and outputs which is greater.
//!
//! Run this example by invoking `cargo run --example minimal`.

use version_compare::{compare, Cmp};

fn main() {
    let a = "1.3";
    let b = "1.2.4";

    match compare(a, b) {
        Ok(Cmp::Lt) => println!("Version a is less than b"),
        Ok(Cmp::Eq) => println!("Version a is equal to b"),
        Ok(Cmp::Gt) => println!("Version a is greater than b"),
        _ => panic!("Invalid version number"),
    }
}