about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-06-18 19:21:17 -0700
committerCorey Farwell <coreyf@rwell.org>2017-06-20 13:49:42 -0400
commit58bbe1d68cddacfd8dca792adb40a6dd04e6d319 (patch)
tree179481c72f9e210fb7f34399da668ba5b5817193 /src/libstd
parent93abc2f87793e1b5a4e7b87c6a47629270be6ad9 (diff)
downloadrust-58bbe1d68cddacfd8dca792adb40a6dd04e6d319.tar.gz
rust-58bbe1d68cddacfd8dca792adb40a6dd04e6d319.zip
Add a couple doc additional examples for `env::join_paths`.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/env.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libstd/env.rs b/src/libstd/env.rs
index 889ba81e778..770bca7524c 100644
--- a/src/libstd/env.rs
+++ b/src/libstd/env.rs
@@ -438,6 +438,35 @@ pub struct JoinPathsError {
 ///
 /// # Examples
 ///
+/// Joining paths on a Unix-like platform:
+///
+/// ```
+/// # if cfg!(unix) {
+/// use std::env;
+/// use std::ffi::OsString;
+/// use std::path::Path;
+///
+/// let paths = [Path::new("/bin"), Path::new("/usr/bin")];
+/// let path_os_string = env::join_paths(paths.iter()).unwrap();
+/// assert_eq!(path_os_string, OsString::from("/bin:/usr/bin"));
+/// # }
+/// ```
+///
+/// Joining a path containing a colon on a Unix-like platform results in an error:
+///
+/// ```
+/// # if cfg!(unix) {
+/// use std::env;
+/// use std::path::Path;
+///
+/// let paths = [Path::new("/bin"), Path::new("/usr/bi:n")];
+/// assert!(env::join_paths(paths.iter()).is_err());
+/// # }
+/// ```
+///
+/// Using `env::join_paths` with `env::spit_paths` to append an item to the `PATH` environment
+/// variable:
+///
 /// ```
 /// use std::env;
 /// use std::path::PathBuf;