Skip to content

Commit

Permalink
Improve documentation on std::os::env.
Browse files Browse the repository at this point in the history
  • Loading branch information
darnuria committed Jun 5, 2014
1 parent f377dfe commit 85adc09
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/libstd/os.rs
Expand Up @@ -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();
Expand Down

5 comments on commit 85adc09

@bors
Copy link
Contributor

@bors bors commented on 85adc09 Jun 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at darnuria@85adc09

@bors
Copy link
Contributor

@bors bors commented on 85adc09 Jun 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging darnuria/rust/add_documentation_to_std_os = 85adc09 into auto

@bors
Copy link
Contributor

@bors bors commented on 85adc09 Jun 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

darnuria/rust/add_documentation_to_std_os = 85adc09 merged ok, testing candidate = 5ec49c7

@bors
Copy link
Contributor

@bors bors commented on 85adc09 Jun 6, 2014

@bors
Copy link
Contributor

@bors bors commented on 85adc09 Jun 6, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 5ec49c7

Please sign in to comment.