diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-06-18 19:21:17 -0700 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2017-06-20 13:49:42 -0400 |
| commit | 58bbe1d68cddacfd8dca792adb40a6dd04e6d319 (patch) | |
| tree | 179481c72f9e210fb7f34399da668ba5b5817193 /src/libstd | |
| parent | 93abc2f87793e1b5a4e7b87c6a47629270be6ad9 (diff) | |
| download | rust-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.rs | 29 |
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; |
