Created
June 12, 2026 20:15
-
-
Save malcolmgreaves/a7ff37a6394f9212af6ab7df956dbe55 to your computer and use it in GitHub Desktop.
Creates a new `pub const &str` that is called `ENV_(string you put in)` and has the exact value of what you put in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// Creates a new `pub const &str` that is called `ENV_(string you put in)` and has the exact value of what you put in. | |
| /// | |
| /// Example: | |
| /// | |
| /// named_env_var!("FOO"); | |
| /// assert_eq!(ENV_FOO, "FOO"); | |
| /// | |
| macro_rules! named_env_var { | |
| ($name:expr) => { | |
| pub const concat!("ENV_", $name): &str = $name; | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment