Skip to content

Commit 4f08d75

Browse files
committed
Mention std::env::var in env!
When searching for how to read an environment variable, I first encountered the `env!` macro. It would have been useful to me if the documentation had included a link to `std::env::var`, which is what I was actually looking for.
1 parent 2ed6786 commit 4f08d75

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

library/core/src/macros/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,10 @@ pub(crate) mod builtin {
909909
/// Inspects an environment variable at compile time.
910910
///
911911
/// This macro will expand to the value of the named environment variable at
912-
/// compile time, yielding an expression of type `&'static str`.
912+
/// compile time, yielding an expression of type `&'static str`. Use
913+
/// [`std::env::var`] instead if you want to read the value at runtime.
914+
///
915+
/// [`std::env::var`]: ../std/env/fn.var.html
913916
///
914917
/// If the environment variable is not defined, then a compilation error
915918
/// will be emitted. To not emit a compile error, use the [`option_env!`]
@@ -950,7 +953,10 @@ pub(crate) mod builtin {
950953
/// expand into an expression of type `Option<&'static str>` whose value is
951954
/// `Some` of the value of the environment variable. If the environment
952955
/// variable is not present, then this will expand to `None`. See
953-
/// [`Option<T>`][Option] for more information on this type.
956+
/// [`Option<T>`][Option] for more information on this type. Use
957+
/// [`std::env::var`] instead if you want to read the value at runtime.
958+
///
959+
/// [`std::env::var`]: ../std/env/fn.var.html
954960
///
955961
/// A compile time error is never emitted when using this macro regardless
956962
/// of whether the environment variable is present or not.

0 commit comments

Comments
 (0)