#const #constant #macro #crate

build pkg-version

Macros expanding to the package version

3 releases (1 stable)

1.0.0 Nov 22, 2019
0.1.2 Oct 5, 2019
0.1.1 Sep 4, 2019
0.1.0 May 3, 2019

#155 in Build Utils

Download history 657/week @ 2023-11-18 1872/week @ 2023-11-25 734/week @ 2023-12-02 867/week @ 2023-12-09 528/week @ 2023-12-16 206/week @ 2023-12-23 890/week @ 2023-12-30 887/week @ 2024-01-06 785/week @ 2024-01-13 598/week @ 2024-01-20 915/week @ 2024-01-27 1107/week @ 2024-02-03 915/week @ 2024-02-10 1307/week @ 2024-02-17 1155/week @ 2024-02-24 676/week @ 2024-03-02

4,238 downloads per month
Used in 22 crates (14 directly)

0BSD license

8KB

pkg-version - Macros for accessing your crate version

crates.io docs.rs Build Status

This crate provides macros (pkg_version_major!, etc.) that expand to the Cargo package version, as an integer literal.

Previously, the only way to access the package version was by using env!("CARGO_PKG_VERSION_MAJOR") etc., but doing that always results in a string literal, which can only be parsed into a number at runtime. This crate fixes that problem by parsing the version during macro expansion.

Please refer to the changelog to see what changed in the last releases.

Usage

Add an entry to your Cargo.toml:

[dependencies]
pkg-version = "1.0.0"

Check the API Documentation for how to use the crate's functionality.

Dependencies