File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -206,11 +206,20 @@ fn with_env_lock<T>(f: || -> T) -> T {
206206 }
207207}
208208
209- /// Returns a vector of (variable, value) pairs for all the environment
210- /// variables of the current process.
209+ /// Returns a vector of (variable, value) pairs as a Vec<(String, String)>,
210+ /// for all the environment variables of the current process.
211211///
212212/// Invalid UTF-8 bytes are replaced with \uFFFD. See `str::from_utf8_lossy()`
213213/// for details.
214+ ///
215+ /// # Example
216+ ///
217+ /// ```rust
218+ /// // We will iterate through the references to the element returned by std::os::env();
219+ /// for &(ref key, ref value) in std::os::env().iter() {
220+ /// println!("'{}': '{}'", key, value );
221+ /// }
222+ /// ```
214223pub fn env ( ) -> Vec < ( String , String ) > {
215224 env_as_bytes ( ) . move_iter ( ) . map ( |( k, v) | {
216225 let k = str:: from_utf8_lossy ( k. as_slice ( ) ) . to_string ( ) ;
You can’t perform that action at this time.
0 commit comments