diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 9c4139853c540..6e19506363817 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -14,6 +14,7 @@ use c_str::{CString, ToCStr}; use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; use collections::{Collection, MutableSeq}; +use fmt; use from_str::FromStr; use hash; use io::Writer; @@ -21,6 +22,7 @@ use iter::{DoubleEndedIterator, AdditiveIterator, Extendable, Iterator, Map}; use option::{Option, None, Some}; use str::Str; use str; +use string::String; use slice::{CloneableVector, Splits, Slice, VectorVector, ImmutablePartialEqSlice, ImmutableSlice}; use vec::Vec; @@ -143,6 +145,12 @@ impl<'a> BytesContainer for &'a Path { } } +impl fmt::Show for Path { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + String::from_utf8_lossy( self.as_vec() ).as_slice().fmt(f) + } +} + impl GenericPathUnsafe for Path { unsafe fn new_unchecked(path: T) -> Path { let path = Path::normalize(path.container_as_bytes()); diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 803db4848ada5..50d35714fbae6 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -17,6 +17,7 @@ use c_str::{CString, ToCStr}; use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; use collections::{Collection, MutableSeq}; +use fmt; use from_str::FromStr; use hash; use io::Writer; @@ -186,6 +187,14 @@ impl<'a> BytesContainer for &'a Path { fn is_str(_: Option<&'a Path>) -> bool { true } } + +impl fmt::Show for Path { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + String::from_utf8_lossy( self.as_vec() ).as_slice().fmt(f) + } +} + + impl GenericPathUnsafe for Path { /// See `GenericPathUnsafe::from_vec_unchecked`. ///