version-rs

Crates.ioversion-rs
lib.rsversion-rs
version0.2.0
sourcesrc
created_at2020-07-03 20:48:37.393188
updated_at2020-08-04 01:26:07.993872
descriptionA struct for Versions, with the methods you expect
homepage
repositoryhttps://github.com/iwahbe/version-rs
max_upload_size
id261113
size9,909
Ian Wahbe (iwahbe)

documentation

README

version-rs

Lots of code which handles other pieces of software involves version numbers. This involves creating approximately the same object with approximately the same 100 lines of code in multiple crates. This crate aims to avoid this boilerplate.

Obligatory Example:

use version::Version;
let v1_2_3 = Version::new(1,2,3);
assert!(v1_2_3 == "1.2.3".parse()?);
assert!(v1_2_3 < Version::new(1,2,12));
assert!(v1_2_3 > Version::from((1,2,0));
let (x, y, z) = random_usize_triple();
assert!(Version::from(x,y,z), (x,y,z).into());

Some quick copy and past ensured that Version works for u8, u16, and u32. To use, add

[dependencies]
version-rs = "0.1"

to your Cargo.toml. If you want to use Version with serde, add version-rs = {version = "0.1", features = ["serde"]} to derive Serialize and Deserialize.

Commit count: 8

cargo fmt