Closed
Description
The documentation for the compiler-built-in macro core::env
/ std::env
currently reads:
macro_rules! env {
($name:expr $(,)?) => { ... };
}
The text and example state that a second parameter can be given to customize the error message in case the environment variable is not defined. This second parameter is not reflected in the syntax above. The following is valid:
fn main() {
let x: &'static str = env!("CARGO_MANIFEST_DIR", "oh no!"); // this should not match `$(name:expr $(,)?)`
}
Looking at the implementation, the syntax should most likely be documented as
macro_rules! env {
($name:expr) => { ... };
($name:expr, $error:expr) => { ... };
}
Am I missing something? I can commit a PR if so desired.