default-env

Crates.iodefault-env
lib.rsdefault-env
version0.1.1
sourcesrc
created_at2019-06-21 02:31:41.604633
updated_at2019-06-21 02:46:18.477659
descriptionThe `env!` macro but with a default value.
homepage
repositoryhttps://github.com/nhynes/default-env
max_upload_size
id142495
size4,534
Nick Hynes (nhynes)

documentation

README

default-env

default_env! is a macro like env! that returns a default value if the environment variable is not found. Unlike option_env!, the output of default_env! can be used in macros (because who doesn't love macros in their macros?).

Example

macro_rules! long_str {
  () => {
    concat!(
        "Hello, ", default_env!("USER", "anonymous user"), ".",
        "Today is ", default_env!("WEEKDAY", compile_error!("You exist in a land beyond time."))
      )
  }
}
Commit count: 2

cargo fmt