pkg/lib.rs
1//! A small utility library for binary applications.
2
3#![no_std]
4#![deny(missing_docs, warnings)]
5
6extern crate core;
7
8mod version;
9
10#[cfg(feature = "build")]
11pub mod build;
12
13#[doc(hidden)]
14pub use core::env as __env;
15
16#[doc(hidden)]
17#[proc_macro_hack::proc_macro_hack]
18pub use pkg_macros::authors as __authors;
19
20/// Expands to the crate name.
21///
22/// # Examples
23///
24/// ```
25/// const NAME: &str = pkg::name!();
26/// ```
27#[macro_export]
28macro_rules! name {
29 () => {
30 $crate::__env!("CARGO_PKG_NAME")
31 };
32}
33
34/// Expands to the full crate version.
35///
36/// # Examples
37///
38/// ```
39/// const VERSION: &str = pkg::version!();
40/// ```
41#[macro_export]
42macro_rules! version {
43 () => {
44 $crate::__env!("CARGO_PKG_VERSION")
45 };
46}
47
48/// Expands to the crate authors.
49///
50/// # Examples
51///
52/// Basic usage:
53/// ```
54/// const AUTHORS: &[&str] = pkg::authors!();
55/// ```
56///
57/// Joined string:
58/// ```
59/// const AUTHORS: &str = pkg::authors!(", ");
60/// ```
61#[macro_export]
62macro_rules! authors {
63 ($join:literal) => {{
64 let authors: &'static str = $crate::__authors!($join);
65 authors
66 }};
67 () => {{
68 let authors: &'static [&'static str] = $crate::__authors!();
69 authors
70 }};
71}
72
73/// Expands to the crate description.
74///
75/// # Examples
76///
77/// ```
78/// const DESCRIPTION: &str = pkg::description!();
79/// ```
80#[macro_export]
81macro_rules! description {
82 () => {
83 $crate::__env!("CARGO_PKG_DESCRIPTION")
84 };
85}
86
87/// Expands to the crate homepage URL.
88///
89/// # Examples
90///
91/// ```
92/// const HOMEPAGE: &str = pkg::homepage!();
93/// ```
94#[macro_export]
95macro_rules! homepage {
96 () => {
97 $crate::__env!("CARGO_PKG_HOMEPAGE")
98 };
99}
100
101/// Expands to the crate homepage URL.
102///
103/// # Examples
104///
105/// ```
106/// const REPOSITORY: &str = pkg::repository!();
107/// ```
108#[macro_export]
109macro_rules! repository {
110 () => {
111 $crate::__env!("CARGO_PKG_REPOSITORY")
112 };
113}