defvar

Crates.iodefvar
lib.rsdefvar
version0.1.0
sourcesrc
created_at2024-08-13 22:18:40.928865
updated_at2024-08-13 22:18:40.928865
descriptionA macro that makes defining environment variables easy
homepagehttps://deadbeef.moe/crates/defvar
repositoryhttps://github.com/javbit/defvar
max_upload_size
id1336560
size4,567
Javed Mohamed (javbit)

documentation

README

Defvar makes defining environment variables easy

Defvar provides a macro for declaring environment variables. It also makes it easy to describe how to parse the value and provide a default.

Usage

use defvar::defvar;
use std::time::Duration;

// Defining simple variables is easy.
defvar! { GREETING: String = "Howdy" }

// The macro supports types other than String.  You can provide your
// own parsing logic.
defvar! { TIMES: usize = 1, or try t => t.parse() }

// Here is a more complicated example.
defvar! { DURATION: Duration = Duration::from_secs(1), or try d => d.parse().map(Duration::from_secs) }
Commit count: 0

cargo fmt