summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-03-31 10:15:33 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-03-31 15:49:11 -0700
commit5e0bda0448283c3045c1e96b99e90ebbc3746e12 (patch)
treea9a841e7127653eea53156ab17ad883670ed1f45 /src/libstd
parent095f1fbde661c4de6dc96fd2e9753b084b66f34a (diff)
parentfe8a66040742f9acd26e5b932550cc0e5d853445 (diff)
downloadrust-5e0bda0448283c3045c1e96b99e90ebbc3746e12.tar.gz
rust-5e0bda0448283c3045c1e96b99e90ebbc3746e12.zip
rollup merge of #23885: steveklabnik/doc_std_env
Just one or two things to finish this module off
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/env.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/libstd/env.rs b/src/libstd/env.rs
index 71f072302fb..c50548081ab 100644
--- a/src/libstd/env.rs
+++ b/src/libstd/env.rs
@@ -261,7 +261,20 @@ pub fn set_var<K: ?Sized, V: ?Sized>(k: &K, v: &V)
     os_imp::setenv(k.as_os_str(), v.as_os_str())
 }
 
-/// Remove a variable from the environment entirely.
+/// Remove an environment variable from the environment of the currently running process.
+///
+/// # Examples
+///
+/// ```
+/// use std::env;
+///
+/// let key = "KEY";
+/// env::set_var(key, "VALUE");
+/// assert_eq!(env::var(key), Ok("VALUE".to_string()));
+///
+/// env::remove_var(key);
+/// assert!(env::var(key).is_err());
+/// ```
 #[stable(feature = "env", since = "1.0.0")]
 pub fn remove_var<K: ?Sized>(k: &K) where K: AsOsStr {
     let _g = ENV_LOCK.lock();
@@ -398,6 +411,19 @@ pub fn home_dir() -> Option<PathBuf> {
 /// On Windows, returns the value of, in order, the 'TMP', 'TEMP',
 /// 'USERPROFILE' environment variable  if any are set and not the empty
 /// string. Otherwise, tmpdir returns the path to the Windows directory.
+///
+/// ```
+/// use std::env;
+/// use std::fs::File;
+///
+/// # fn foo() -> std::io::Result<()> {
+/// let mut dir = env::temp_dir();
+/// dir.push("foo.txt");
+///
+/// let f = try!(File::create(dir));
+/// # Ok(())
+/// # }
+/// ```
 #[stable(feature = "env", since = "1.0.0")]
 pub fn temp_dir() -> PathBuf {
     os_imp::temp_dir()
@@ -557,6 +583,7 @@ pub mod consts {
     #[stable(feature = "env", since = "1.0.0")]
     pub const ARCH: &'static str = super::arch::ARCH;
 
+    /// The family of the operating system. In this case, `unix`.
     #[stable(feature = "env", since = "1.0.0")]
     pub const FAMILY: &'static str = super::os::FAMILY;