defvar 0.3.0

A macro that makes defining environment variables easy
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 8.54 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 244.56 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • javbit/defvar
    2 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • javbit

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) }