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
@@ -71,15 +78,17 @@ pub fn set_current_dir<P: AsRef<Path>>(p: P) -> io::Result<()> {
71
78
72
79
/// An iterator over a snapshot of the environment variables of this process.
73
80
///
74
- /// This structure is created through the [`std::env::vars`] function.
81
+ /// This structure is created by the [`std::env::vars`] function. See its
82
+ /// documentation for more.
75
83
///
76
84
/// [`std::env::vars`]: fn.vars.html
77
85
#[ stable( feature = "env" , since = "1.0.0" ) ]
78
86
pub struct Vars { inner : VarsOs }
79
87
80
88
/// An iterator over a snapshot of the environment variables of this process.
81
89
///
82
- /// This structure is created through the [`std::env::vars_os`] function.
90
+ /// This structure is created by the [`std::env::vars_os`] function. See
91
+ /// its documentation for more.
83
92
///
84
93
/// [`std::env::vars_os`]: fn.vars_os.html
85
94
#[ stable( feature = "env" , since = "1.0.0" ) ]
@@ -173,12 +182,10 @@ impl fmt::Debug for VarsOs {
173
182
174
183
/// Fetches the environment variable `key` from the current process.
175
184
///
176
- /// The returned result is [`Ok(s)`] if the environment variable is present and is
177
- /// valid unicode. If the environment variable is not present, or it is not
178
- /// valid unicode, then [`Err`] will be returned.
185
+ /// # Errors
179
186
///
180
- /// [`Ok(s)`]: ../result/enum.Result.html#variant.Ok
181
- /// [`Err`]: ../result/enum.Result.html#variant.Err
187
+ /// * Environment variable is not present
188
+ /// * Environment variable is not valid unicode
182
189
///
183
190
/// # Examples
184
191
///
@@ -230,7 +237,8 @@ fn _var_os(key: &OsStr) -> Option<OsString> {
230
237
} )
231
238
}
232
239
233
- /// Possible errors from the [`env::var`] function.
240
+ /// The error type for operations interacting with environment variables.
241
+ /// Possibly returned from the [`env::var`] function.
234
242
///
235
243
/// [`env::var`]: fn.var.html
236
244
#[ derive( Debug , PartialEq , Eq , Clone ) ]
@@ -353,10 +361,13 @@ fn _remove_var(k: &OsStr) {
353
361
} )
354
362
}
355
363
356
- /// An iterator over `PathBuf` instances for parsing an environment variable
357
- /// according to platform-specific conventions.
364
+ /// An iterator that splits an environment variable into paths according to
365
+ /// platform-specific conventions.
358
366
///
359
- /// This structure is returned from `std::env::split_paths`.
367
+ /// This structure is created by the [`std::env::split_paths`] function See its
368
+ /// documentation for more.
369
+ ///
370
+ /// [`std::env::split_paths`]: fn.split_paths.html
360
371
#[ stable( feature = "env" , since = "1.0.0" ) ]
361
372
pub struct SplitPaths < ' a > { inner : os_imp:: SplitPaths < ' a > }
362
373
@@ -399,8 +410,10 @@ impl<'a> fmt::Debug for SplitPaths<'a> {
399
410
}
400
411
}
401
412
402
- /// Error type returned from `std::env::join_paths` when paths fail to be
403
- /// joined.
413
+ /// The error type for operations on the `PATH` variable. Possibly returned from
414
+ /// the [`env::join_paths`] function.
415
+ ///
416
+ /// [`env::join_paths`]: fn.join_paths.html
404
417
#[ derive( Debug ) ]
405
418
#[ stable( feature = "env" , since = "1.0.0" ) ]
406
419
pub struct JoinPathsError {
@@ -410,15 +423,15 @@ pub struct JoinPathsError {
410
423
/// Joins a collection of [`Path`]s appropriately for the `PATH`
411
424
/// environment variable.
412
425
///
413
- /// Returns an [`OsString`] on success.
426
+ /// # Errors
414
427
///
415
- /// Returns an [`Err`][err] (containing an error message) if one of the input
428
+ /// Returns an [`Err`] (containing an error message) if one of the input
416
429
/// [`Path`]s contains an invalid character for constructing the `PATH`
417
430
/// variable (a double quote on Windows or a colon on Unix).
418
431
///
419
432
/// [`Path`]: ../../std/path/struct.Path.html
420
433
/// [`OsString`]: ../../std/ffi/struct.OsString.html
421
- /// [err ]: ../../std/result/enum.Result.html#variant.Err
434
+ /// [`Err` ]: ../../std/result/enum.Result.html#variant.Err
422
435
///
423
436
/// # Examples
424
437
///
@@ -490,12 +503,16 @@ pub fn home_dir() -> Option<PathBuf> {
490
503
491
504
/// Returns the path of a temporary directory.
492
505
///
493
- /// On Unix, returns the value of the `TMPDIR` environment variable if it is
506
+ /// # Unix
507
+ ///
508
+ /// Returns the value of the `TMPDIR` environment variable if it is
494
509
/// set, otherwise for non-Android it returns `/tmp`. If Android, since there
495
510
/// is no global temporary folder (it is usually allocated per-app), it returns
496
511
/// `/data/local/tmp`.
497
512
///
498
- /// On Windows, returns the value of, in order, the `TMP`, `TEMP`,
513
+ /// # Windows
514
+ ///
515
+ /// Returns the value of, in order, the `TMP`, `TEMP`,
499
516
/// `USERPROFILE` environment variable if any are set and not the empty
500
517
/// string. Otherwise, `temp_dir` returns the path of the Windows directory.
501
518
/// This behavior is identical to that of [`GetTempPath`][msdn], which this
0 commit comments