@@ -28,18 +28,20 @@ fn make_case_insensitive_and_normalized_env(
28
28
( case_insensitive_env, normalized_env)
29
29
}
30
30
31
- /// A snapshot of the environment variables available to [`super:: GlobalContext`].
31
+ /// A snapshot of the environment variables available to [`GlobalContext`].
32
32
///
33
- /// Currently, the [`Context`](super::GlobalContext) supports lookup of environment variables
33
+ /// Currently, the [`GlobalContext`] supports lookup of environment variables
34
34
/// through two different means:
35
35
///
36
- /// - [`Context ::get_env`](super::GlobalContext::get_env)
37
- /// and [`Context ::get_env_os`](super::GlobalContext::get_env_os)
36
+ /// - [`GlobalContext ::get_env`](super::GlobalContext::get_env)
37
+ /// and [`GlobalContext ::get_env_os`](super::GlobalContext::get_env_os)
38
38
/// for process environment variables (similar to [`std::env::var`] and [`std::env::var_os`]),
39
- /// - Typed Config Value API via [`Context ::get`](super::GlobalContext::get).
39
+ /// - Typed Config Value API via [`GlobalContext ::get`](super::GlobalContext::get).
40
40
/// This is only available for `CARGO_` prefixed environment keys.
41
41
///
42
42
/// This type contains the env var snapshot and helper methods for both APIs.
43
+ ///
44
+ /// [`GlobalContext`]: super::GlobalContext
43
45
#[ derive( Debug ) ]
44
46
pub struct Env {
45
47
/// A snapshot of the process's environment variables.
@@ -68,8 +70,8 @@ impl Env {
68
70
pub fn new ( ) -> Self {
69
71
// ALLOWED: This is the only permissible usage of `std::env::vars{_os}`
70
72
// within cargo. If you do need access to individual variables without
71
- // interacting with `Config` system, please use `std::env::var{_os}`
72
- // and justify the validity of the usage.
73
+ // interacting with the config system in [`GlobalContext`] , please use
74
+ // `std::env::var{_os}` and justify the validity of the usage.
73
75
#[ allow( clippy:: disallowed_methods) ]
74
76
let env: HashMap < _ , _ > = std:: env:: vars_os ( ) . collect ( ) ;
75
77
let ( case_insensitive_env, normalized_env) = make_case_insensitive_and_normalized_env ( & env) ;
@@ -105,9 +107,10 @@ impl Env {
105
107
self . env . keys ( ) . filter_map ( |k| k. to_str ( ) )
106
108
}
107
109
108
- /// Get the value of environment variable `key` through the `Config` snapshot.
110
+ /// Get the value of environment variable `key` through the snapshot in
111
+ /// [`GlobalContext`](super::GlobalContext).
109
112
///
110
- /// This can be used similarly to `std::env::var_os`.
113
+ /// This can be used similarly to [ `std::env::var_os`] .
111
114
/// On Windows, we check for case mismatch since environment keys are case-insensitive.
112
115
pub fn get_env_os ( & self , key : impl AsRef < OsStr > ) -> Option < OsString > {
113
116
match self . env . get ( key. as_ref ( ) ) {
@@ -152,7 +155,7 @@ impl Env {
152
155
/// Get the value of environment variable `key` as a `&str`.
153
156
/// Returns `None` if `key` is not in `self.env` or if the value is not valid UTF-8.
154
157
///
155
- /// This is intended for use in private methods of `Config` ,
158
+ /// This is intended for use in private methods of [`GlobalContext`](super::GlobalContext) ,
156
159
/// and does not check for env key case mismatch.
157
160
///
158
161
/// This is case-sensitive on Windows (even though environment keys on Windows are usually
@@ -172,7 +175,7 @@ impl Env {
172
175
173
176
/// Check if the environment contains `key`.
174
177
///
175
- /// This is intended for use in private methods of `Config` ,
178
+ /// This is intended for use in private methods of [`GlobalContext`](super::GlobalContext) ,
176
179
/// and does not check for env key case mismatch.
177
180
/// See the docstring of [`Env::get_str`] for more context.
178
181
pub ( super ) fn contains_key ( & self , key : impl AsRef < OsStr > ) -> bool {
0 commit comments