Function join_paths
fn join_paths<I, T>(paths: I) -> Result<crate::ffi::OsString, JoinPathsError>
where
I: IntoIterator<Item = T>,
T: AsRef<crate::ffi::OsStr>
Joins a collection of Paths appropriately for the PATH
environment variable.
Errors
Returns an Err (containing an error message) if one of the input
Paths contains an invalid character for constructing the PATH
variable (a double quote on Windows or a colon on Unix), or if the system
does not have a PATH-like variable (e.g. UEFI or WASI).
Examples
Joining paths on a Unix-like platform:
use env;
use OsString;
use Path;
Joining a path containing a colon on a Unix-like platform results in an error:
# if cfg!
Using env::join_paths() with env::split_paths() to append an item to
the PATH environment variable:
use env;
use PathBuf;