std::env::join_paths - Rust
Description: API documentation for the Rust `join_paths` fn in crate `std`.
Keywords: rust, rustlang, rust-lang, join_paths

# Function std::env::join_paths 1.0.0 [−] [src]

    pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError> where I: IntoIterator<Item=T>, T: AsRef<OsStr>

Joins a collection of `Path`s appropriately for the `PATH` environment variable.

Returns an `OsString` on success.

Returns an `Err` (containing an error message) if one of the input `Path`s contains an invalid character for constructing the `PATH` variable (a double quote on Windows or a colon on Unix).

# Examples

    use std::env;
    use std::path::PathBuf;

    if let Some(path) = env::var_os("PATH") {
        let mut paths = env::split_paths(&path).collect::<Vec<_>>();
        paths.push(PathBuf::from("/home/xyz/bin"));
        let new_path = env::join_paths(paths).unwrap();
        env::set_var("PATH", &new_path);
    }Run

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)