use ffi::{OsString, AsOsStr};
use fmt;
use io;
-use path::{AsPath, PathBuf};
+use path::{Path, PathBuf};
use sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT, Ordering};
use sync::{StaticMutex, MUTEX_INIT};
use sys::os as os_imp;
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// // We assume that we are in a valid directory.
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
/// use std::path::Path;
///
/// println!("Successfully changed working directory to {}!", root.display());
/// ```
#[stable(feature = "env", since = "1.0.0")]
-pub fn set_current_dir<P: AsPath + ?Sized>(p: &P) -> io::Result<()> {
- os_imp::chdir(p.as_path())
+pub fn set_current_dir<P: AsRef<Path> + ?Sized>(p: &P) -> io::Result<()> {
+ os_imp::chdir(p.as_ref())
}
static ENV_LOCK: StaticMutex = MUTEX_INIT;
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// // We will iterate through the references to the element returned by
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// // We will iterate through the references to the element returned by
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// let key = "HOME";
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// let key = "HOME";
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// let key = "KEY";
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// let key = "PATH";
///
/// # Examples
///
-/// ```rust
+/// ```
/// 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::new("/home/xyz/bin"));
+/// paths.push(PathBuf::from("/home/xyz/bin"));
/// let new_path = env::join_paths(paths.iter()).unwrap();
/// env::set_var("PATH", &new_path);
/// }
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// match env::home_dir() {
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// match env::current_exe() {
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// // Prints each argument on a separate line
///
/// # Examples
///
-/// ```rust
+/// ```
/// use std::env;
///
/// // Prints each argument on a separate line
mod tests {
use prelude::v1::*;
use super::*;
+
use iter::repeat;
use rand::{self, Rng};
use ffi::{OsString, OsStr};
- use path::PathBuf;
+ use path::{Path, PathBuf};
fn make_rand_name() -> OsString {
let mut rng = rand::thread_rng();
fn split_paths_windows() {
fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
split_paths(unparsed).collect::<Vec<_>>() ==
- parsed.iter().map(|s| PathBuf::new(*s)).collect::<Vec<_>>()
+ parsed.iter().map(|s| PathBuf::from(*s)).collect::<Vec<_>>()
}
assert!(check_parse("", &mut [""]));
fn split_paths_unix() {
fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
split_paths(unparsed).collect::<Vec<_>>() ==
- parsed.iter().map(|s| PathBuf::new(*s)).collect::<Vec<_>>()
+ parsed.iter().map(|s| PathBuf::from(*s)).collect::<Vec<_>>()
}
assert!(check_parse("", &mut [""]));