about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAxel Viala <axel.viala@darnuria.eu>2014-06-05 17:36:15 +0200
committerAxel Viala <axel.viala@darnuria.eu>2014-06-05 17:36:15 +0200
commit85adc09b19a437dab822fe67db908207aaa541b9 (patch)
tree5f1837319468a1c01b8e832e22fca1007ce7d511 /src/libstd
parentf377dfe5acfd7023d535a94cfe9466276affc6da (diff)
downloadrust-85adc09b19a437dab822fe67db908207aaa541b9.tar.gz
rust-85adc09b19a437dab822fe67db908207aaa541b9.zip
Improve documentation on std::os::env.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/os.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index eae4ca42201..a93be701f53 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -206,11 +206,20 @@ fn with_env_lock<T>(f: || -> T) -> T {
     }
 }
 
-/// Returns a vector of (variable, value) pairs for all the environment
-/// variables of the current process.
+/// Returns a vector of (variable, value) pairs as a Vec<(String, String)>,
+/// for all the environment variables of the current process.
 ///
 /// Invalid UTF-8 bytes are replaced with \uFFFD. See `str::from_utf8_lossy()`
 /// for details.
+///
+/// # Example
+///
+/// ```rust
+/// // We will iterate through the references to the element returned by std::os::env();
+/// for &(ref key, ref value) in std::os::env().iter() {
+///     println!("'{}': '{}'", key, value );
+/// }
+/// ```
 pub fn env() -> Vec<(String,String)> {
     env_as_bytes().move_iter().map(|(k,v)| {
         let k = str::from_utf8_lossy(k.as_slice()).to_string();