https://github.com/rob2309/env-cast-rs
Macro to parse an environment variable into a numeric type at compile time
https://github.com/rob2309/env-cast-rs
Last synced: over 1 year ago
JSON representation
Macro to parse an environment variable into a numeric type at compile time
- Host: GitHub
- URL: https://github.com/rob2309/env-cast-rs
- Owner: Rob2309
- License: mit
- Created: 2022-02-15T07:05:50.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T09:29:58.000Z (over 3 years ago)
- Last Synced: 2025-03-10T04:50:16.393Z (over 1 year ago)
- Language: Rust
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# env-cast

[](https://crates.io/crates/env-cast)
[](https://github.com/Rob2309/env-cast-rs/actions/workflows/ci.yaml)
[](https://docs.rs/env-cast)
`env_cast!` reads an environment variable just like `env!("XXX")`, but parses it into a specific type.
Supported types are currently
`i8, u8, i16, u16, i32, u32, i64, u64, f32, f64`.
## Example
```rust
use env_cast::env_cast;
let PKG_MAJOR: u32 = env_cast!("CARGO_PKG_VERSION_MAJOR" as u32);
```