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 {
206
206
}
207
207
}
208
208
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.
211
211
///
212
212
/// Invalid UTF-8 bytes are replaced with \uFFFD. See `str::from_utf8_lossy()`
213
213
/// 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
+ /// ```
214
223
pub fn env ( ) -> Vec < ( String , String ) > {
215
224
env_as_bytes ( ) . move_iter ( ) . map ( |( k, v) | {
216
225
let k = str:: from_utf8_lossy ( k. as_slice ( ) ) . to_string ( ) ;
You can’t perform that action at this time.
0 commit comments