diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/path.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys_common/wtf8.rs | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index c90a0c78527..c657e5638d0 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -3953,4 +3953,10 @@ mod tests { assert_eq!(path, path_buf); assert!(path_buf.into_os_string().capacity() >= 15); } + + #[test] + fn display_format_flags() { + assert_eq!(format!("a{:#<5}b", Path::new("").display()), "a#####b"); + assert_eq!(format!("a{:#<5}b", Path::new("a").display()), "aa####b"); + } } diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 4e4a6e77d12..b89a73cd28a 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -452,10 +452,14 @@ impl fmt::Display for Wtf8 { pos = surrogate_pos + 3; }, None => { - formatter.write_str(unsafe { + let s = unsafe { str::from_utf8_unchecked(&wtf8_bytes[pos..]) - })?; - return Ok(()); + }; + if pos == 0 { + return s.fmt(formatter) + } else { + return formatter.write_str(s) + } } } } |
