#version #numbers

version-rs

A struct for Versions, with the methods you expect

3 unstable releases

0.2.0 Aug 4, 2020
0.1.1 Jul 28, 2020
0.1.0 Jul 3, 2020

#1889 in Data structures


Used in brew

MIT/Apache

10KB
223 lines

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.

Dependencies

~160KB