13
13
//! This module contains functions to inspect various aspects such as
14
14
//! environment variables, process arguments, the current directory, and various
15
15
//! other important directories.
16
+ //!
17
+ //! There are several functions and structs in this module that have a
18
+ //! counterpart ending in `os`. Those ending in `os` will return an [`OsString`]
19
+ //! and those without will be returning a [`String`].
20
+ //!
21
+ //! [`OsString`]: ../../std/ffi/struct.OsString.html
22
+ //! [`String`]: ../string/struct.String.html
16
23
17
24
#![ stable( feature = "env" , since = "1.0.0" ) ]
18
25
@@ -74,15 +81,17 @@ pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
74
81
75
82
/// An iterator over a snapshot of the environment variables of this process.
76
83
///
77
- /// This structure is created through the [`std::env::vars`] function.
84
+ /// This structure is created by the [`std::env::vars`] function. See its
85
+ /// documentation for more.
78
86
///
79
87
/// [`std::env::vars`]: fn.vars.html
80
88
#[ stable( feature = "env" , since = "1.0.0" ) ]
81
89
pub struct Vars { inner : VarsOs }
82
90
83
91
/// An iterator over a snapshot of the environment variables of this process.
84
92
///
85
- /// This structure is created through the [`std::env::vars_os`] function.
93
+ /// This structure is created by the [`std::env::vars_os`] function. See
94
+ /// its documentation for more.
86
95
///
87
96
/// [`std::env::vars_os`]: fn.vars_os.html
88
97
#[ stable( feature = "env" , since = "1.0.0" ) ]
@@ -176,12 +185,10 @@ impl fmt::Debug for VarsOs {
176
185
177
186
/// Fetches the environment variable `key` from the current process.
178
187
///
179
- /// The returned result is [`Ok(s)`] if the environment variable is present and is
180
- /// valid unicode. If the environment variable is not present, or it is not
181
- /// valid unicode, then [`VarError`] will be returned.
188
+ /// # Errors
182
189
///
183
- /// [`Ok(s)`]: ../result/enum.Result.html#variant.Ok
184
- /// [`VarError`]: enum.VarError.html
190
+ /// * Environment variable is not present
191
+ /// * Environment variable is not valid unicode
185
192
///
186
193
/// # Examples
187
194
///
@@ -233,7 +240,8 @@ fn _var_os(key: &OsStr) -> Option<OsString> {
233
240
} )
234
241
}
235
242
236
- /// Possible errors from the [`env::var`] function.
243
+ /// The error type for operations interacting with environment variables.
244
+ /// Possibly returned from the [`env::var`] function.
237
245
///
238
246
/// [`env::var`]: fn.var.html
239
247
#[ derive( Debug , PartialEq , Eq , Clone ) ]
@@ -356,10 +364,13 @@ fn _remove_var(k: &OsStr) {
356
364
} )
357
365
}
358
366
359
- /// An iterator over `PathBuf` instances for parsing an environment variable
360
- /// according to platform-specific conventions.
367
+ /// An iterator that splits an environment variable into paths according to
368
+ /// platform-specific conventions.
361
369
///
362
- /// This structure is returned from `std::env::split_paths`.
370
+ /// This structure is created by the [`std::env::split_paths`] function See its
371
+ /// documentation for more.
372
+ ///
373
+ /// [`std::env::split_paths`]: fn.split_paths.html
363
374
#[ stable( feature = "env" , since = "1.0.0" ) ]
364
375
pub struct SplitPaths < ' a > { inner : os_imp:: SplitPaths < ' a > }
365
376
@@ -402,8 +413,10 @@ impl<'a> fmt::Debug for SplitPaths<'a> {
402
413
}
403
414
}
404
415
405
- /// Error type returned from `std::env::join_paths` when paths fail to be
406
- /// joined.
416
+ /// The error type for operations on the `PATH` variable. Possibly returned from
417
+ /// the [`env::join_paths`] function.
418
+ ///
419
+ /// [`env::join_paths`]: fn.join_paths.html
407
420
#[ derive( Debug ) ]
408
421
#[ stable( feature = "env" , since = "1.0.0" ) ]
409
422
pub struct JoinPathsError {
@@ -413,7 +426,7 @@ pub struct JoinPathsError {
413
426
/// Joins a collection of [`Path`]s appropriately for the `PATH`
414
427
/// environment variable.
415
428
///
416
- /// Returns an [`OsString`] on success.
429
+ /// # Errors
417
430
///
418
431
/// Returns an [`Err`][err] (containing an error message) if one of the input
419
432
/// [`Path`]s contains an invalid character for constructing the `PATH`
@@ -493,12 +506,16 @@ pub fn home_dir() -> Option<PathBuf> {
493
506
494
507
/// Returns the path of a temporary directory.
495
508
///
496
- /// On Unix, returns the value of the `TMPDIR` environment variable if it is
509
+ /// # Unix
510
+ ///
511
+ /// Returns the value of the `TMPDIR` environment variable if it is
497
512
/// set, otherwise for non-Android it returns `/tmp`. If Android, since there
498
513
/// is no global temporary folder (it is usually allocated per-app), it returns
499
514
/// `/data/local/tmp`.
500
515
///
501
- /// On Windows, returns the value of, in order, the `TMP`, `TEMP`,
516
+ /// # Windows
517
+ ///
518
+ /// Returns the value of, in order, the `TMP`, `TEMP`,
502
519
/// `USERPROFILE` environment variable if any are set and not the empty
503
520
/// string. Otherwise, `temp_dir` returns the path of the Windows directory.
504
521
/// This behavior is identical to that of [`GetTempPath`][msdn], which this
0 commit comments