Crates.io | simple-version |
lib.rs | simple-version |
version | |
source | src |
created_at | 2024-09-03 06:42:37.030444 |
updated_at | 2025-01-03 08:19:18.34789 |
description | The easiest way to manage versions in rust. |
homepage | |
repository | |
max_upload_size | |
id | 1361379 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A small Rust library that provides a Version<T>
type for handling semantic versioning,
including an optional build number. It also offers a version_from_pkg!
macro to embed
the crate's compile-time CARGO_PKG_VERSION
directly into your code.
Version
object(without a build number)
use simple_version::Version;
let v = Version::<u32>::new(1, 2, 3);
println!("{}", v); // 1.2.3
Version
object(with a build number)
use simple_version::Version;
let v = Version::<u32>::new(1, 2, 3).build(4);
println!("{}", v); // 1.2.3+4
Version
object(using the Cargo package version)
# Cargo.toml
[package]
name = "..."
version = "1.2.3"
...
use simple_version::{Version, version_from_pkg};
let v: Version<u32> = version_from_pkg!(u32);
println!("{}", v); // 1.2.3
use simple_version::Version;
let v1 = Version::<u32>::new(1, 999, 999);
let v2 = Version::<u32>::new(2, 0, 0);
assert!(v1 < v2);
(with exceptions)
use simple_version::Version;
let v1 = Version::<u32>::new(1, 0, 0).build(1); // v1 has a build number.
let v2 = Version::<u32>::new(1, 0, 0); // v2 does not.
assert!(v1 > v2); // In this case, v1 is greater.