]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/env.rs
Stabilize `std::convert` and related code
[rust.git] / src / libstd / env.rs
index 4b6fbe01f760bbe0b19b85d22f21a34b6561f55a..6553b40b745ec13d671d02677bbfcc6a42a4b020 100644 (file)
@@ -23,7 +23,7 @@
 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;
@@ -67,8 +67,8 @@ pub fn current_dir() -> io::Result<PathBuf> {
 /// 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;
@@ -332,7 +332,7 @@ pub struct JoinPathsError {
 ///
 /// 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);
 /// }
@@ -729,10 +729,11 @@ mod arch {
 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();
@@ -832,7 +833,7 @@ fn test() {
     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 [""]));
@@ -852,7 +853,7 @@ fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
     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 [""]));