Rollup merge of #125206 - mgeisler:simplify-std-env-vars, r=jhpratt,tgross35
Simplify environment variable examples I’ve found myself visiting the documentation for `std::env::vars` every few months, and every time I do, it is because I want to quickly get a snippet to print out all environment variables :-) So I think it could be nice to simplify the examples a little to make them self-contained. It is of course a style question if one should import a module a not, but I personally don’t import modules used just once in a code snippet.
This commit is contained in:
commit
689d27293a
1 changed files with 4 additions and 10 deletions
|
@ -120,11 +120,8 @@ pub struct VarsOs {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::env;
|
/// // Print all environment variables.
|
||||||
///
|
/// for (key, value) in std::env::vars() {
|
||||||
/// // We will iterate through the references to the element returned by
|
|
||||||
/// // env::vars();
|
|
||||||
/// for (key, value) in env::vars() {
|
|
||||||
/// println!("{key}: {value}");
|
/// println!("{key}: {value}");
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -150,11 +147,8 @@ pub fn vars() -> Vars {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::env;
|
/// // Print all environment variables.
|
||||||
///
|
/// for (key, value) in std::env::vars_os() {
|
||||||
/// // We will iterate through the references to the element returned by
|
|
||||||
/// // env::vars_os();
|
|
||||||
/// for (key, value) in env::vars_os() {
|
|
||||||
/// println!("{key:?}: {value:?}");
|
/// println!("{key:?}: {value:?}");
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue