@@ -261,7 +261,20 @@ pub fn set_var<K: ?Sized, V: ?Sized>(k: &K, v: &V)
261
261
os_imp:: setenv ( k. as_os_str ( ) , v. as_os_str ( ) )
262
262
}
263
263
264
- /// Remove a variable from the environment entirely.
264
+ /// Remove an environment variable from the environment of the currently running process.
265
+ ///
266
+ /// # Examples
267
+ ///
268
+ /// ```
269
+ /// use std::env;
270
+ ///
271
+ /// let key = "KEY";
272
+ /// env::set_var(key, "VALUE");
273
+ /// assert_eq!(env::var(key), Ok("VALUE".to_string()));
274
+ ///
275
+ /// env::remove_var(key);
276
+ /// assert!(env::var(key).is_err());
277
+ /// ```
265
278
#[ stable( feature = "env" , since = "1.0.0" ) ]
266
279
pub fn remove_var < K : ?Sized > ( k : & K ) where K : AsOsStr {
267
280
let _g = ENV_LOCK . lock ( ) ;
@@ -398,6 +411,19 @@ pub fn home_dir() -> Option<PathBuf> {
398
411
/// On Windows, returns the value of, in order, the 'TMP', 'TEMP',
399
412
/// 'USERPROFILE' environment variable if any are set and not the empty
400
413
/// string. Otherwise, tmpdir returns the path to the Windows directory.
414
+ ///
415
+ /// ```
416
+ /// use std::env;
417
+ /// use std::fs::File;
418
+ ///
419
+ /// # fn foo() -> std::io::Result<()> {
420
+ /// let mut dir = env::temp_dir();
421
+ /// dir.push("foo.txt");
422
+ ///
423
+ /// let f = try!(File::create(dir));
424
+ /// # Ok(())
425
+ /// # }
426
+ /// ```
401
427
#[ stable( feature = "env" , since = "1.0.0" ) ]
402
428
pub fn temp_dir ( ) -> PathBuf {
403
429
os_imp:: temp_dir ( )
@@ -557,6 +583,7 @@ pub mod consts {
557
583
#[ stable( feature = "env" , since = "1.0.0" ) ]
558
584
pub const ARCH : & ' static str = super :: arch:: ARCH ;
559
585
586
+ /// The family of the operating system. In this case, `unix`.
560
587
#[ stable( feature = "env" , since = "1.0.0" ) ]
561
588
pub const FAMILY : & ' static str = super :: os:: FAMILY ;
562
589
0 commit comments