Skip to content

Commit ed539e1

Browse files
committed
path2: Remove Path::normalize()
There are no clients of this API, so just remove it. Update the module docstring to mention normalization.
1 parent eaec8a7 commit ed539e1

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/libstd/path/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Option<&str> with `.as_str()`. Similarly, attributes of the path can be queried
4343
with methods such as `.filename()`. There are also methods that return a new
4444
path instead of modifying the receiver, such as `.join()` or `.dir_path()`.
4545
46+
Paths are always kept in normalized form. This means that creating the path
47+
`Path::from_str("a/b/../c")` will return the path `a/c`. Similarly any attempt
48+
to mutate the path will always leave it in normalized form.
49+
4650
When rendering a path to some form of display, there is a method `.display()`
4751
which is compatible with the `format!()` parameter `{}`. This will render the
4852
path as a string, replacing all non-utf8 sequences with the Replacement

src/libstd/path/posix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl Path {
349349

350350
/// Returns a normalized byte vector representation of a path, by removing all empty
351351
/// components, and unnecessary . and .. components.
352-
pub fn normalize<V: Vector<u8>+CopyableVector<u8>>(v: V) -> ~[u8] {
352+
fn normalize<V: Vector<u8>+CopyableVector<u8>>(v: V) -> ~[u8] {
353353
// borrowck is being very picky
354354
let val = {
355355
let is_abs = !v.as_slice().is_empty() && v.as_slice()[0] == sep;

src/libstd/path/windows.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,13 +697,6 @@ impl Path {
697697
Some(self.repr)
698698
}
699699

700-
/// Returns a normalized string representation of a path, by removing all empty
701-
/// components, and unnecessary . and .. components.
702-
pub fn normalize<S: Str>(s: S) -> ~str {
703-
let (_, path) = Path::normalize_(s);
704-
path
705-
}
706-
707700
/// Returns an iterator that yields each component of the path in turn as a Option<&str>.
708701
/// Every component is guaranteed to be Some.
709702
/// Does not yield the path prefix (including server/share components in UNC paths).

0 commit comments

Comments
 (0)