Add new path module
Implements [RFC 474](https://github.com/rust-lang/rfcs/pull/474); see that RFC for details/motivation for this change. This initial commit does not include additional normalization or platform-specific path extensions. These will be done in follow up commits or PRs.
This commit is contained in:
parent
3e39f0bc0e
commit
45ddf50ceb
8 changed files with 2576 additions and 9 deletions
|
@ -24,6 +24,7 @@ pub use self::os_str::OsStr;
|
||||||
mod c_str;
|
mod c_str;
|
||||||
mod os_str;
|
mod os_str;
|
||||||
|
|
||||||
|
// FIXME (#21670): these should be defined in the os_str module
|
||||||
/// Freely convertible to an `&OsStr` slice.
|
/// Freely convertible to an `&OsStr` slice.
|
||||||
pub trait AsOsStr {
|
pub trait AsOsStr {
|
||||||
/// Convert to an `&OsStr` slice.
|
/// Convert to an `&OsStr` slice.
|
||||||
|
|
|
@ -41,7 +41,7 @@ use string::{String, CowString};
|
||||||
use ops;
|
use ops;
|
||||||
use cmp;
|
use cmp;
|
||||||
use hash::{Hash, Hasher, Writer};
|
use hash::{Hash, Hasher, Writer};
|
||||||
use path::{Path, GenericPath};
|
use old_path::{Path, GenericPath};
|
||||||
|
|
||||||
use sys::os_str::{Buf, Slice};
|
use sys::os_str::{Buf, Slice};
|
||||||
use sys_common::{AsInner, IntoInner, FromInner};
|
use sys_common::{AsInner, IntoInner, FromInner};
|
||||||
|
|
2567
src/libstd/path.rs
Executable file
2567
src/libstd/path.rs
Executable file
File diff suppressed because it is too large
Load diff
|
@ -20,7 +20,7 @@ use str;
|
||||||
use string::{String, CowString};
|
use string::{String, CowString};
|
||||||
use mem;
|
use mem;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Hash)]
|
||||||
pub struct Buf {
|
pub struct Buf {
|
||||||
pub inner: Vec<u8>
|
pub inner: Vec<u8>
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ use result::Result;
|
||||||
use option::Option;
|
use option::Option;
|
||||||
use mem;
|
use mem;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Hash)]
|
||||||
pub struct Buf {
|
pub struct Buf {
|
||||||
pub inner: Wtf8Buf
|
pub inner: Wtf8Buf
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
use std::slice::SliceExt;
|
use std::slice::SliceExt;
|
||||||
use std::old_io::{Command, fs, USER_RWX};
|
use std::old_io::{Command, fs, USER_RWX};
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::path::BytesContainer;
|
use std::old_path::BytesContainer;
|
||||||
use std::rand::random;
|
use std::rand::random;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
||||||
// file at the top-level directory of this distribution and at
|
// file at the top-level directory of this distribution and at
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
@ -15,8 +14,8 @@
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![feature(unboxed_closures)]
|
#![feature(unboxed_closures)]
|
||||||
|
|
||||||
use std::path::{Path};
|
use std::old_path::{Path};
|
||||||
use std::path;
|
use std::old_path;
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::thunk::Thunk;
|
use std::thunk::Thunk;
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ fn tester()
|
||||||
result::Result::Ok("more blah".to_string())
|
result::Result::Ok("more blah".to_string())
|
||||||
};
|
};
|
||||||
|
|
||||||
let path = path::Path::new("blah");
|
let path = old_path::Path::new("blah");
|
||||||
assert!(loader(&path).is_ok());
|
assert!(loader(&path).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use std::old_io;
|
||||||
use std::old_io::fs;
|
use std::old_io::fs;
|
||||||
use std::old_io::Command;
|
use std::old_io::Command;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::path::Path;
|
use std::old_path::Path;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let my_args = os::args();
|
let my_args = os::args();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue