Skip to content

Commit

Permalink
Fix bug where option_env! would return None when env var is prese…
Browse files Browse the repository at this point in the history
…nt but not valid Unicode
  • Loading branch information
beetrees committed Oct 13, 2024
1 parent 7420c36 commit 6fc4b1a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,17 +1107,19 @@ pub(crate) mod builtin {
///
/// If the named environment variable is present at compile time, this will
/// expand into an expression of type `Option<&'static str>` whose value is
/// `Some` of the value of the environment variable. If the environment
/// variable is not present, then this will expand to `None`. See
/// [`Option<T>`][Option] for more information on this type. Use
/// [`std::env::var`] instead if you want to read the value at runtime.
/// `Some` of the value of the environment variable (a compilation error
/// will be emitted if the environment variable is not a valid Unicode
/// string). If the environment variable is not present, then this will
/// expand to `None`. See [`Option<T>`][Option] for more information on this
/// type. Use [`std::env::var`] instead if you want to read the value at
/// runtime.
///
/// [`std::env::var`]: ../std/env/fn.var.html
///
/// A compile time error is never emitted when using this macro regardless
/// of whether the environment variable is present or not.
/// To emit a compile error if the environment variable is not present,
/// use the [`env!`] macro instead.
/// A compile time error is only emitted when using this macro if the
/// environment variable exists and is not a valid Unicode string. To also
/// emit a compile error if the environment variable is not present, use the
/// [`env!`] macro instead.
///
/// # Examples
///
Expand Down

0 comments on commit 6fc4b1a

Please sign in to comment.