File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -438,6 +438,35 @@ pub struct JoinPathsError {
438
438
///
439
439
/// # Examples
440
440
///
441
+ /// Joining paths on a Unix-like platform:
442
+ ///
443
+ /// ```
444
+ /// # if cfg!(unix) {
445
+ /// use std::env;
446
+ /// use std::ffi::OsString;
447
+ /// use std::path::Path;
448
+ ///
449
+ /// let paths = [Path::new("/bin"), Path::new("/usr/bin")];
450
+ /// let path_os_string = env::join_paths(paths.iter()).unwrap();
451
+ /// assert_eq!(path_os_string, OsString::from("/bin:/usr/bin"));
452
+ /// # }
453
+ /// ```
454
+ ///
455
+ /// Joining a path containing a colon on a Unix-like platform results in an error:
456
+ ///
457
+ /// ```
458
+ /// # if cfg!(unix) {
459
+ /// use std::env;
460
+ /// use std::path::Path;
461
+ ///
462
+ /// let paths = [Path::new("/bin"), Path::new("/usr/bi:n")];
463
+ /// assert!(env::join_paths(paths.iter()).is_err());
464
+ /// # }
465
+ /// ```
466
+ ///
467
+ /// Using `env::join_paths` with `env::spit_paths` to append an item to the `PATH` environment
468
+ /// variable:
469
+ ///
441
470
/// ```
442
471
/// use std::env;
443
472
/// use std::path::PathBuf;
You can’t perform that action at this time.
0 commit comments