1
Fork 0

Deal with the fallout of string stabilization

This commit is contained in:
Alex Crichton 2014-09-22 08:28:35 -07:00
parent 31be3319bf
commit 50375139e2
13 changed files with 88 additions and 74 deletions

View file

@ -444,7 +444,8 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
"-nx".to_string(), "-nx".to_string(),
format!("-command={}", debugger_script.as_str().unwrap())); format!("-command={}", debugger_script.as_str().unwrap()));
let gdb_path = tool_path.append("/bin/arm-linux-androideabi-gdb"); let mut gdb_path = tool_path;
gdb_path.push_str("/bin/arm-linux-androideabi-gdb");
let procsrv::Result { let procsrv::Result {
out, out,
err, err,

View file

@ -698,7 +698,7 @@ pub trait StrAllocating: Str {
let me = self.as_slice(); let me = self.as_slice();
let mut out = String::with_capacity(me.len()); let mut out = String::with_capacity(me.len());
for c in me.chars() { for c in me.chars() {
c.escape_default(|c| out.push_char(c)); c.escape_default(|c| out.push(c));
} }
out out
} }
@ -708,7 +708,7 @@ pub trait StrAllocating: Str {
let me = self.as_slice(); let me = self.as_slice();
let mut out = String::with_capacity(me.len()); let mut out = String::with_capacity(me.len());
for c in me.chars() { for c in me.chars() {
c.escape_unicode(|c| out.push_char(c)); c.escape_unicode(|c| out.push(c));
} }
out out
} }

View file

@ -159,7 +159,7 @@ impl String {
if i > 0 { if i > 0 {
unsafe { unsafe {
res.push_bytes(v.slice_to(i)) res.as_mut_vec().push_all(v.slice_to(i))
}; };
} }
@ -176,10 +176,10 @@ impl String {
macro_rules! error(() => ({ macro_rules! error(() => ({
unsafe { unsafe {
if subseqidx != i_ { if subseqidx != i_ {
res.push_bytes(v.slice(subseqidx, i_)); res.as_mut_vec().push_all(v.slice(subseqidx, i_));
} }
subseqidx = i; subseqidx = i;
res.push_bytes(REPLACEMENT); res.as_mut_vec().push_all(REPLACEMENT);
} }
})) }))
@ -245,7 +245,7 @@ impl String {
} }
if subseqidx < total { if subseqidx < total {
unsafe { unsafe {
res.push_bytes(v.slice(subseqidx, total)) res.as_mut_vec().push_all(v.slice(subseqidx, total))
}; };
} }
Owned(res.into_string()) Owned(res.into_string())
@ -271,7 +271,7 @@ impl String {
let mut s = String::with_capacity(v.len() / 2); let mut s = String::with_capacity(v.len() / 2);
for c in str::utf16_items(v) { for c in str::utf16_items(v) {
match c { match c {
str::ScalarValue(c) => s.push_char(c), str::ScalarValue(c) => s.push(c),
str::LoneSurrogate(_) => return None str::LoneSurrogate(_) => return None
} }
} }
@ -332,6 +332,7 @@ impl String {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// # #![allow(deprecated)]
/// let s = String::from_str("hello"); /// let s = String::from_str("hello");
/// let big = s.append(" ").append("world").append("!"); /// let big = s.append(" ").append("world").append("!");
/// // s has now been moved and cannot be used /// // s has now been moved and cannot be used
@ -362,11 +363,11 @@ impl String {
} }
let mut buf = String::new(); let mut buf = String::new();
buf.push_char(ch); buf.push(ch);
let size = buf.len() * length; let size = buf.len() * length;
buf.reserve(size); buf.reserve(size);
for _ in range(1, length) { for _ in range(1, length) {
buf.push_char(ch) buf.push(ch)
} }
buf buf
} }
@ -380,6 +381,7 @@ impl String {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// # #![allow(deprecated)]
/// let s = String::from_byte(104); /// let s = String::from_byte(104);
/// assert_eq!(s.as_slice(), "h"); /// assert_eq!(s.as_slice(), "h");
/// ``` /// ```
@ -417,7 +419,7 @@ impl String {
#[unstable = "duplicate of iterator-based functionality"] #[unstable = "duplicate of iterator-based functionality"]
pub fn grow(&mut self, count: uint, ch: char) { pub fn grow(&mut self, count: uint, ch: char) {
for _ in range(0, count) { for _ in range(0, count) {
self.push_char(ch) self.push(ch)
} }
} }
@ -426,6 +428,7 @@ impl String {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// # #![allow(deprecated)]
/// let s = String::with_capacity(10); /// let s = String::with_capacity(10);
/// assert!(s.byte_capacity() >= 10); /// assert!(s.byte_capacity() >= 10);
/// ``` /// ```
@ -441,7 +444,7 @@ impl String {
/// ///
/// ``` /// ```
/// let s = String::with_capacity(10); /// let s = String::with_capacity(10);
/// assert!(s.byte_capacity() >= 10); /// assert!(s.capacity() >= 10);
/// ``` /// ```
#[inline] #[inline]
#[unstable = "just implemented, needs to prove itself"] #[unstable = "just implemented, needs to prove itself"]
@ -455,9 +458,9 @@ impl String {
/// ///
/// ``` /// ```
/// let mut s = String::with_capacity(10); /// let mut s = String::with_capacity(10);
/// let before = s.byte_capacity(); /// let before = s.capacity();
/// s.reserve_additional(100); /// s.reserve_additional(100);
/// assert!(s.byte_capacity() - before >= 100); /// assert!(s.capacity() - before >= 100);
/// ``` /// ```
#[inline] #[inline]
pub fn reserve_additional(&mut self, extra: uint) { pub fn reserve_additional(&mut self, extra: uint) {
@ -471,7 +474,7 @@ impl String {
/// ``` /// ```
/// let mut s = String::new(); /// let mut s = String::new();
/// s.reserve(10); /// s.reserve(10);
/// assert!(s.byte_capacity() >= 10); /// assert!(s.capacity() >= 10);
/// ``` /// ```
#[inline] #[inline]
pub fn reserve(&mut self, capacity: uint) { pub fn reserve(&mut self, capacity: uint) {
@ -485,7 +488,7 @@ impl String {
/// ``` /// ```
/// let mut s = String::new(); /// let mut s = String::new();
/// s.reserve_exact(10); /// s.reserve_exact(10);
/// assert_eq!(s.byte_capacity(), 10); /// assert_eq!(s.capacity(), 10);
/// ``` /// ```
#[inline] #[inline]
pub fn reserve_exact(&mut self, capacity: uint) { pub fn reserve_exact(&mut self, capacity: uint) {
@ -499,9 +502,9 @@ impl String {
/// ``` /// ```
/// let mut s = String::from_str("foo"); /// let mut s = String::from_str("foo");
/// s.reserve(100); /// s.reserve(100);
/// assert!(s.byte_capacity() >= 100); /// assert!(s.capacity() >= 100);
/// s.shrink_to_fit(); /// s.shrink_to_fit();
/// assert_eq!(s.byte_capacity(), 3); /// assert_eq!(s.capacity(), 3);
/// ``` /// ```
#[inline] #[inline]
pub fn shrink_to_fit(&mut self) { pub fn shrink_to_fit(&mut self) {
@ -527,7 +530,7 @@ impl String {
/// assert_eq!(s.as_slice(), "abc123"); /// assert_eq!(s.as_slice(), "abc123");
/// ``` /// ```
#[inline] #[inline]
#[stable = "function just renamed from push_char"] #[stable = "function just renamed from push"]
pub fn push(&mut self, ch: char) { pub fn push(&mut self, ch: char) {
let cur_len = self.len(); let cur_len = self.len();
// This may use up to 4 bytes. // This may use up to 4 bytes.
@ -552,6 +555,7 @@ impl String {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// # #![allow(deprecated)]
/// let mut s = String::new(); /// let mut s = String::new();
/// unsafe { /// unsafe {
/// s.push_bytes([104, 101, 108, 108, 111]); /// s.push_bytes([104, 101, 108, 108, 111]);
@ -587,6 +591,7 @@ impl String {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// # #![allow(deprecated)]
/// let mut s = String::from_str("hello"); /// let mut s = String::from_str("hello");
/// unsafe { /// unsafe {
/// let bytes = s.as_mut_bytes(); /// let bytes = s.as_mut_bytes();
@ -598,7 +603,7 @@ impl String {
/// assert_eq!(s.as_slice(), "h3ll0") /// assert_eq!(s.as_slice(), "h3ll0")
/// ``` /// ```
#[inline] #[inline]
#[deprecated = "call .as_mut_vec().as_slice() instead"] #[deprecated = "call .as_mut_vec().as_mut_slice() instead"]
pub unsafe fn as_mut_bytes<'a>(&'a mut self) -> &'a mut [u8] { pub unsafe fn as_mut_bytes<'a>(&'a mut self) -> &'a mut [u8] {
self.vec.as_mut_slice() self.vec.as_mut_slice()
} }
@ -631,6 +636,7 @@ impl String {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// # #![allow(deprecated)]
/// let mut s = String::from_str("hell"); /// let mut s = String::from_str("hell");
/// unsafe { /// unsafe {
/// s.push_byte(111); /// s.push_byte(111);
@ -652,6 +658,7 @@ impl String {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// # #![allow(deprecated)]
/// let mut s = String::from_str("foo"); /// let mut s = String::from_str("foo");
/// unsafe { /// unsafe {
/// assert_eq!(s.pop_byte(), Some(111)); /// assert_eq!(s.pop_byte(), Some(111));
@ -714,6 +721,7 @@ impl String {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// # #![allow(deprecated)]
/// let mut s = String::from_str("foo"); /// let mut s = String::from_str("foo");
/// unsafe { /// unsafe {
/// assert_eq!(s.shift_byte(), Some(102)); /// assert_eq!(s.shift_byte(), Some(102));
@ -722,7 +730,7 @@ impl String {
/// assert_eq!(s.shift_byte(), None); /// assert_eq!(s.shift_byte(), None);
/// } /// }
/// ``` /// ```
#[deprecated = "call .as_mut_rev().remove(0)"] #[deprecated = "call .as_mut_vec().remove(0)"]
pub unsafe fn shift_byte(&mut self) -> Option<u8> { pub unsafe fn shift_byte(&mut self) -> Option<u8> {
self.vec.remove(0) self.vec.remove(0)
} }
@ -782,6 +790,7 @@ impl String {
/// ///
/// If `idx` does not lie on a character boundary or is out of bounds, then /// If `idx` does not lie on a character boundary or is out of bounds, then
/// this function will fail. /// this function will fail.
#[unstable = "the failure semantics of this function are uncertain"]
pub fn insert(&mut self, idx: uint, ch: char) { pub fn insert(&mut self, idx: uint, ch: char) {
let len = self.len(); let len = self.len();
assert!(idx <= len); assert!(idx <= len);
@ -854,7 +863,7 @@ impl FromIterator<char> for String {
impl Extendable<char> for String { impl Extendable<char> for String {
fn extend<I:Iterator<char>>(&mut self, mut iterator: I) { fn extend<I:Iterator<char>>(&mut self, mut iterator: I) {
for ch in iterator { for ch in iterator {
self.push_char(ch) self.push(ch)
} }
} }
} }
@ -1171,13 +1180,13 @@ mod tests {
} }
#[test] #[test]
fn test_push_char() { fn test_push() {
let mut data = String::from_str("ประเทศไทย中"); let mut data = String::from_str("ประเทศไทย中");
data.push_char('华'); data.push('华');
data.push_char('b'); // 1 byte data.push('b'); // 1 byte
data.push_char('¢'); // 2 byte data.push('¢'); // 2 byte
data.push_char('€'); // 3 byte data.push('€'); // 3 byte
data.push_char('𤭢'); // 4 byte data.push('𤭢'); // 4 byte
assert_eq!(data.as_slice(), "ประเทศไทย中华b¢€𤭢"); assert_eq!(data.as_slice(), "ประเทศไทย中华b¢€𤭢");
} }

View file

@ -685,9 +685,9 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
match short_name.len() { match short_name.len() {
0 => {} 0 => {}
1 => { 1 => {
row.push_char('-'); row.push('-');
row.push_str(short_name.as_slice()); row.push_str(short_name.as_slice());
row.push_char(' '); row.push(' ');
} }
_ => fail!("the short name should only be 1 ascii char long"), _ => fail!("the short name should only be 1 ascii char long"),
} }
@ -698,7 +698,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
_ => { _ => {
row.push_str("--"); row.push_str("--");
row.push_str(long_name.as_slice()); row.push_str(long_name.as_slice());
row.push_char(' '); row.push(' ');
} }
} }
@ -707,9 +707,9 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
No => {} No => {}
Yes => row.push_str(hint.as_slice()), Yes => row.push_str(hint.as_slice()),
Maybe => { Maybe => {
row.push_char('['); row.push('[');
row.push_str(hint.as_slice()); row.push_str(hint.as_slice());
row.push_char(']'); row.push(']');
} }
} }
@ -718,7 +718,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
let rowlen = row.as_slice().char_len(); let rowlen = row.as_slice().char_len();
if rowlen < 24 { if rowlen < 24 {
for _ in range(0, 24 - rowlen) { for _ in range(0, 24 - rowlen) {
row.push_char(' '); row.push(' ');
} }
} else { } else {
row.push_str(desc_sep.as_slice()) row.push_str(desc_sep.as_slice())
@ -728,7 +728,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
let mut desc_normalized_whitespace = String::new(); let mut desc_normalized_whitespace = String::new();
for word in desc.as_slice().words() { for word in desc.as_slice().words() {
desc_normalized_whitespace.push_str(word); desc_normalized_whitespace.push_str(word);
desc_normalized_whitespace.push_char(' '); desc_normalized_whitespace.push(' ');
} }
// FIXME: #5516 should be graphemes not codepoints // FIXME: #5516 should be graphemes not codepoints
@ -755,12 +755,12 @@ fn format_option(opt: &OptGroup) -> String {
let mut line = String::new(); let mut line = String::new();
if opt.occur != Req { if opt.occur != Req {
line.push_char('['); line.push('[');
} }
// Use short_name is possible, but fallback to long_name. // Use short_name is possible, but fallback to long_name.
if opt.short_name.len() > 0 { if opt.short_name.len() > 0 {
line.push_char('-'); line.push('-');
line.push_str(opt.short_name.as_slice()); line.push_str(opt.short_name.as_slice());
} else { } else {
line.push_str("--"); line.push_str("--");
@ -768,18 +768,18 @@ fn format_option(opt: &OptGroup) -> String {
} }
if opt.hasarg != No { if opt.hasarg != No {
line.push_char(' '); line.push(' ');
if opt.hasarg == Maybe { if opt.hasarg == Maybe {
line.push_char('['); line.push('[');
} }
line.push_str(opt.hint.as_slice()); line.push_str(opt.hint.as_slice());
if opt.hasarg == Maybe { if opt.hasarg == Maybe {
line.push_char(']'); line.push(']');
} }
} }
if opt.occur != Req { if opt.occur != Req {
line.push_char(']'); line.push(']');
} }
if opt.occur == Multi { if opt.occur == Multi {
line.push_str(".."); line.push_str("..");

View file

@ -426,7 +426,7 @@ impl<'a> LabelText<'a> {
fn escape_str(s: &str) -> String { fn escape_str(s: &str) -> String {
let mut out = String::with_capacity(s.len()); let mut out = String::with_capacity(s.len());
for c in s.chars() { for c in s.chars() {
LabelText::escape_char(c, |c| out.push_char(c)); LabelText::escape_char(c, |c| out.push(c));
} }
out out
} }
@ -461,9 +461,11 @@ impl<'a> LabelText<'a> {
/// Puts `suffix` on a line below this label, with a blank line separator. /// Puts `suffix` on a line below this label, with a blank line separator.
pub fn suffix_line(self, suffix: LabelText) -> LabelText<'static> { pub fn suffix_line(self, suffix: LabelText) -> LabelText<'static> {
let prefix = self.pre_escaped_content().into_string(); let mut prefix = self.pre_escaped_content().into_string();
let suffix = suffix.pre_escaped_content(); let suffix = suffix.pre_escaped_content();
EscStr(str::Owned(prefix.append(r"\n\n").append(suffix.as_slice()))) prefix.push_str(r"\n\n");
prefix.push_str(suffix.as_slice());
EscStr(str::Owned(prefix))
} }
} }

View file

@ -105,7 +105,7 @@ impl Program {
let mut pre = String::with_capacity(5); let mut pre = String::with_capacity(5);
for inst in c.insts.slice_from(1).iter() { for inst in c.insts.slice_from(1).iter() {
match *inst { match *inst {
OneChar(c, FLAG_EMPTY) => pre.push_char(c), OneChar(c, FLAG_EMPTY) => pre.push(c),
_ => break _ => break
} }
} }

View file

@ -26,9 +26,9 @@ pub fn quote(text: &str) -> String {
let mut quoted = String::with_capacity(text.len()); let mut quoted = String::with_capacity(text.len());
for c in text.chars() { for c in text.chars() {
if parse::is_punct(c) { if parse::is_punct(c) {
quoted.push_char('\\') quoted.push('\\')
} }
quoted.push_char(c); quoted.push(c);
} }
quoted quoted
} }
@ -504,7 +504,8 @@ impl Regex {
new.push_str(rep.reg_replace(&cap).as_slice()); new.push_str(rep.reg_replace(&cap).as_slice());
last_match = e; last_match = e;
} }
new.append(text.slice(last_match, text.len())) new.push_str(text.slice(last_match, text.len()));
return new;
} }
/// Returns the original string of this regex. /// Returns the original string of this regex.

View file

@ -1961,9 +1961,9 @@ fn lit_to_string(lit: &ast::Lit) -> String {
ast::LitByte(b) => { ast::LitByte(b) => {
let mut res = String::from_str("b'"); let mut res = String::from_str("b'");
(b as char).escape_default(|c| { (b as char).escape_default(|c| {
res.push_char(c); res.push(c);
}); });
res.push_char('\''); res.push('\'');
res res
}, },
ast::LitChar(c) => format!("'{}'", c), ast::LitChar(c) => format!("'{}'", c),

View file

@ -64,7 +64,7 @@ pub fn load_external_files(names: &[String]) -> Option<String> {
let mut out = String::new(); let mut out = String::new();
for name in names.iter() { for name in names.iter() {
out.push_str(load_or_return!(name.as_slice(), None, None).as_slice()); out.push_str(load_or_return!(name.as_slice(), None, None).as_slice());
out.push_char('\n'); out.push('\n');
} }
Some(out) Some(out)
} }

View file

@ -1080,7 +1080,8 @@ impl Context {
let mut json_out = BufferedWriter::new(try!(File::create(json_dst))); let mut json_out = BufferedWriter::new(try!(File::create(json_dst)));
try!(stability.encode(&mut json::Encoder::new(&mut json_out))); try!(stability.encode(&mut json::Encoder::new(&mut json_out)));
let title = stability.name.clone().append(" - Stability dashboard"); let mut title = stability.name.clone();
title.push_str(" - Stability dashboard");
let desc = format!("API stability overview for the Rust `{}` crate.", let desc = format!("API stability overview for the Rust `{}` crate.",
this.layout.krate); this.layout.krate);
let page = layout::Page { let page = layout::Page {

View file

@ -276,7 +276,7 @@ pub fn collapse_docs(krate: clean::Crate) -> plugins::PluginResult {
clean::NameValue(ref x, ref s) clean::NameValue(ref x, ref s)
if "doc" == x.as_slice() => { if "doc" == x.as_slice() => {
docstr.push_str(s.as_slice()); docstr.push_str(s.as_slice());
docstr.push_char('\n'); docstr.push('\n');
}, },
_ => () _ => ()
} }

View file

@ -1514,14 +1514,14 @@ impl<T: Iterator<char>> Parser<T> {
if escape { if escape {
match self.ch_or_null() { match self.ch_or_null() {
'"' => res.push_char('"'), '"' => res.push('"'),
'\\' => res.push_char('\\'), '\\' => res.push('\\'),
'/' => res.push_char('/'), '/' => res.push('/'),
'b' => res.push_char('\x08'), 'b' => res.push('\x08'),
'f' => res.push_char('\x0c'), 'f' => res.push('\x0c'),
'n' => res.push_char('\n'), 'n' => res.push('\n'),
'r' => res.push_char('\r'), 'r' => res.push('\r'),
't' => res.push_char('\t'), 't' => res.push('\t'),
'u' => match try!(self.decode_hex_escape()) { 'u' => match try!(self.decode_hex_escape()) {
0xDC00 .. 0xDFFF => return self.error(LoneLeadingSurrogateInHexEscape), 0xDC00 .. 0xDFFF => return self.error(LoneLeadingSurrogateInHexEscape),
@ -1535,13 +1535,13 @@ impl<T: Iterator<char>> Parser<T> {
let buf = [n1, try!(self.decode_hex_escape())]; let buf = [n1, try!(self.decode_hex_escape())];
match str::utf16_items(buf.as_slice()).next() { match str::utf16_items(buf.as_slice()).next() {
Some(ScalarValue(c)) => res.push_char(c), Some(ScalarValue(c)) => res.push(c),
_ => return self.error(LoneLeadingSurrogateInHexEscape), _ => return self.error(LoneLeadingSurrogateInHexEscape),
} }
} }
n => match char::from_u32(n as u32) { n => match char::from_u32(n as u32) {
Some(c) => res.push_char(c), Some(c) => res.push(c),
None => return self.error(InvalidUnicodeCodePoint), None => return self.error(InvalidUnicodeCodePoint),
}, },
}, },
@ -1556,7 +1556,7 @@ impl<T: Iterator<char>> Parser<T> {
self.bump(); self.bump();
return Ok(res); return Ok(res);
}, },
Some(c) => res.push_char(c), Some(c) => res.push(c),
None => unreachable!() None => unreachable!()
} }
} }

View file

@ -212,7 +212,7 @@ impl GenericPathUnsafe for Path {
None if ".." == self.repr.as_slice() => { None if ".." == self.repr.as_slice() => {
let mut s = String::with_capacity(3 + filename.len()); let mut s = String::with_capacity(3 + filename.len());
s.push_str(".."); s.push_str("..");
s.push_char(SEP); s.push(SEP);
s.push_str(filename); s.push_str(filename);
self.update_normalized(s); self.update_normalized(s);
} }
@ -222,7 +222,7 @@ impl GenericPathUnsafe for Path {
Some((_,idxa,end)) if self.repr.as_slice().slice(idxa,end) == ".." => { Some((_,idxa,end)) if self.repr.as_slice().slice(idxa,end) == ".." => {
let mut s = String::with_capacity(end + 1 + filename.len()); let mut s = String::with_capacity(end + 1 + filename.len());
s.push_str(self.repr.as_slice().slice_to(end)); s.push_str(self.repr.as_slice().slice_to(end));
s.push_char(SEP); s.push(SEP);
s.push_str(filename); s.push_str(filename);
self.update_normalized(s); self.update_normalized(s);
} }
@ -235,7 +235,7 @@ impl GenericPathUnsafe for Path {
Some((idxb,_,_)) => { Some((idxb,_,_)) => {
let mut s = String::with_capacity(idxb + 1 + filename.len()); let mut s = String::with_capacity(idxb + 1 + filename.len());
s.push_str(self.repr.as_slice().slice_to(idxb)); s.push_str(self.repr.as_slice().slice_to(idxb));
s.push_char(SEP); s.push(SEP);
s.push_str(filename); s.push_str(filename);
self.update_normalized(s); self.update_normalized(s);
} }
@ -299,7 +299,7 @@ impl GenericPathUnsafe for Path {
match me.prefix { match me.prefix {
Some(DiskPrefix) if me.repr.len() == plen => (), Some(DiskPrefix) if me.repr.len() == plen => (),
_ if !(me.repr.len() > plen && me.repr.as_bytes()[me.repr.len()-1] == SEP_BYTE) => { _ if !(me.repr.len() > plen && me.repr.as_bytes()[me.repr.len()-1] == SEP_BYTE) => {
s.push_char(SEP); s.push(SEP);
} }
_ => () _ => ()
} }
@ -745,7 +745,7 @@ impl Path {
Some(VerbatimUNCPrefix(x, 0)) if s.len() == 8 + x => { Some(VerbatimUNCPrefix(x, 0)) if s.len() == 8 + x => {
// the server component has no trailing '\' // the server component has no trailing '\'
let mut s = String::from_str(s); let mut s = String::from_str(s);
s.push_char(SEP); s.push(SEP);
Some(s) Some(s)
} }
_ => None _ => None
@ -815,20 +815,20 @@ impl Path {
let mut s = String::with_capacity(n); let mut s = String::with_capacity(n);
match prefix { match prefix {
Some(DiskPrefix) => { Some(DiskPrefix) => {
s.push_char(prefix_.as_bytes()[0].to_ascii() s.push(prefix_.as_bytes()[0].to_ascii()
.to_uppercase().to_char()); .to_uppercase().to_char());
s.push_char(':'); s.push(':');
} }
Some(VerbatimDiskPrefix) => { Some(VerbatimDiskPrefix) => {
s.push_str(prefix_.slice_to(4)); s.push_str(prefix_.slice_to(4));
s.push_char(prefix_.as_bytes()[4].to_ascii() s.push(prefix_.as_bytes()[4].to_ascii()
.to_uppercase().to_char()); .to_uppercase().to_char());
s.push_str(prefix_.slice_from(5)); s.push_str(prefix_.slice_from(5));
} }
Some(UNCPrefix(a,b)) => { Some(UNCPrefix(a,b)) => {
s.push_str("\\\\"); s.push_str("\\\\");
s.push_str(prefix_.slice(2, a+2)); s.push_str(prefix_.slice(2, a+2));
s.push_char(SEP); s.push(SEP);
s.push_str(prefix_.slice(3+a, 3+a+b)); s.push_str(prefix_.slice(3+a, 3+a+b));
} }
Some(_) => s.push_str(prefix_), Some(_) => s.push_str(prefix_),
@ -842,7 +842,7 @@ impl Path {
} }
} }
for comp in it { for comp in it {
s.push_char(SEP); s.push(SEP);
s.push_str(comp); s.push_str(comp);
} }
Some(s) Some(s)