Skip to content

Commit 28a7a39

Browse files
Add (unstable) documentation for --env command line option
1 parent bafdbae commit 28a7a39

File tree

1 file changed

+21
-0
lines changed
  • src/doc/unstable-book/src/compiler-flags

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# `env`
2+
3+
The tracking issue for this feature is: [#118372](https://github.com/rust-lang/rust/issues/118372).
4+
5+
------------------------
6+
7+
This option flag allows to specify environment variables value at compile time to be
8+
used by `env!` and `option_env!` macros.
9+
10+
When retrieving and environment variable value, the one specified by `--env` will take
11+
precedence. For example if you want have `PATH=a` in your environment and pass:
12+
13+
```bash
14+
rustc --env PATH=env
15+
```
16+
17+
Then you will have:
18+
19+
```rust
20+
assert_eq!(env!("PATH"), "env");
21+
```

0 commit comments

Comments
 (0)