about summary refs log tree commit diff
path: root/library/std/src/env.rs
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2024-07-16 20:10:09 -0500
committerGitHub <noreply@github.com>2024-07-16 20:10:09 -0500
commit689d27293ac04905d230b8fce89aadb42f96a29a (patch)
tree2160b40fc10bf9eeac0f6afa77689224e2b33996 /library/std/src/env.rs
parent7d356ebde329df5f38186efe3e7c5e8dabac7cb7 (diff)
parent62e29fe25b039b89ad76a6b9a94f8085eee934d9 (diff)
downloadrust-689d27293ac04905d230b8fce89aadb42f96a29a.tar.gz
rust-689d27293ac04905d230b8fce89aadb42f96a29a.zip
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.
Diffstat (limited to 'library/std/src/env.rs')
-rw-r--r--library/std/src/env.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/library/std/src/env.rs b/library/std/src/env.rs
index 36add02d68c..fc9b8cfd46d 100644
--- a/library/std/src/env.rs
+++ b/library/std/src/env.rs
@@ -120,11 +120,8 @@ pub struct VarsOs {
 /// # Examples
 ///
 /// ```
-/// use std::env;
-///
-/// // We will iterate through the references to the element returned by
-/// // env::vars();
-/// for (key, value) in env::vars() {
+/// // Print all environment variables.
+/// for (key, value) in std::env::vars() {
 ///     println!("{key}: {value}");
 /// }
 /// ```
@@ -150,11 +147,8 @@ pub fn vars() -> Vars {
 /// # Examples
 ///
 /// ```
-/// use std::env;
-///
-/// // We will iterate through the references to the element returned by
-/// // env::vars_os();
-/// for (key, value) in env::vars_os() {
+/// // Print all environment variables.
+/// for (key, value) in std::env::vars_os() {
 ///     println!("{key:?}: {value:?}");
 /// }
 /// ```