Skip to content

Commit b4ed64d

Browse files
committed
Upgrade to rustc 1.0.0-nightly (458a6a2f6 2015-01-25 21:20:37 +0000)
1 parent af26537 commit b4ed64d

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/lib.rs

+20-16
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Copy for CodePoint {}
5454

5555
/// Format the code point as `U+` followed by four to six hexadecimal digits.
5656
/// Example: `U+1F4A9`
57-
impl fmt::Show for CodePoint {
57+
impl fmt::Debug for CodePoint {
5858
#[inline]
5959
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
6060
write!(formatter, "U+{:04X}", self.value)
@@ -138,7 +138,7 @@ impl Deref for Wtf8Buf {
138138
/// Format the string with double quotes,
139139
/// and surrogates as `\u` followed by four hexadecimal digits.
140140
/// Example: `"a\u{D800}"` for a string with code points [U+0061, U+D800]
141-
impl fmt::Show for Wtf8Buf {
141+
impl fmt::Debug for Wtf8Buf {
142142
#[inline]
143143
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
144144
self.as_slice().fmt(formatter)
@@ -257,7 +257,7 @@ impl Wtf8Buf {
257257
(Some(lead), Some(trail)) => {
258258
let len_without_lead_surrogate = self.len() - 3;
259259
self.bytes.truncate(len_without_lead_surrogate);
260-
let other_without_trail_surrogate = other.bytes.slice_from(3);
260+
let other_without_trail_surrogate = &other.bytes[3..];
261261
// 4 bytes for the supplementary code point
262262
self.bytes.reserve(4 + other_without_trail_surrogate.len());
263263
self.push_char(decode_surrogate_pair(lead, trail));
@@ -337,7 +337,7 @@ impl Wtf8Buf {
337337
Some((surrogate_pos, _)) => {
338338
pos = surrogate_pos + 3;
339339
slice::bytes::copy_memory(
340-
self.bytes.slice_mut(surrogate_pos, pos),
340+
&mut self.bytes[surrogate_pos..pos],
341341
UTF8_REPLACEMENT_CHARACTER
342342
);
343343
},
@@ -418,7 +418,7 @@ impl Ord for Wtf8 {
418418
/// Format the slice with double quotes,
419419
/// and surrogates as `\u` followed by four hexadecimal digits.
420420
/// Example: `"a\u{D800}"` for a slice with code points [U+0061, U+D800]
421-
impl fmt::Show for Wtf8 {
421+
impl fmt::Debug for Wtf8 {
422422
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
423423
try!(formatter.write_str("\""));
424424
let mut pos = 0;
@@ -427,15 +427,15 @@ impl fmt::Show for Wtf8 {
427427
None => break,
428428
Some((surrogate_pos, surrogate)) => {
429429
try!(formatter.write_str(unsafe {
430-
str::from_utf8_unchecked(self.bytes.slice(pos, surrogate_pos))
430+
str::from_utf8_unchecked(&self.bytes[pos..surrogate_pos])
431431
}));
432432
try!(write!(formatter, "\\u{{{:X}}}", surrogate));
433433
pos = surrogate_pos + 3;
434434
}
435435
}
436436
}
437437
try!(formatter.write_str(unsafe {
438-
str::from_utf8_unchecked(self.bytes.slice_from(pos))
438+
str::from_utf8_unchecked(&self.bytes[pos..])
439439
}));
440440
formatter.write_str("\"")
441441
}
@@ -579,18 +579,18 @@ impl Wtf8 {
579579
};
580580
let wtf8_bytes = &self.bytes;
581581
let mut utf8_bytes = Vec::with_capacity(self.len());
582-
utf8_bytes.push_all(wtf8_bytes.slice_to(surrogate_pos));
582+
utf8_bytes.push_all(&wtf8_bytes[..surrogate_pos]);
583583
utf8_bytes.push_all(UTF8_REPLACEMENT_CHARACTER);
584584
let mut pos = surrogate_pos + 3;
585585
loop {
586586
match self.next_surrogate(pos) {
587587
Some((surrogate_pos, _)) => {
588-
utf8_bytes.push_all(wtf8_bytes.slice(pos, surrogate_pos));
588+
utf8_bytes.push_all(&wtf8_bytes[pos..surrogate_pos]);
589589
utf8_bytes.push_all(UTF8_REPLACEMENT_CHARACTER);
590590
pos = surrogate_pos + 3;
591591
},
592592
None => {
593-
utf8_bytes.push_all(wtf8_bytes.slice_from(pos));
593+
utf8_bytes.push_all(&wtf8_bytes[pos..]);
594594
return Cow::Owned(unsafe { String::from_utf8_unchecked(utf8_bytes) })
595595
}
596596
}
@@ -610,7 +610,7 @@ impl Wtf8 {
610610

611611
#[inline]
612612
fn next_surrogate(&self, mut pos: usize) -> Option<(usize, u16)> {
613-
let mut iter = self.bytes.slice_from(pos).iter();
613+
let mut iter = self.bytes[pos..].iter();
614614
loop {
615615
let b = match iter.next() {
616616
None => return None,
@@ -647,7 +647,7 @@ impl Wtf8 {
647647
if len < 3 {
648648
return None
649649
}
650-
match self.bytes.slice_from(len - 3) {
650+
match &self.bytes[len - 3..] {
651651
[0xED, b2 @ 0xA0...0xAF, b3] => Some(decode_surrogate(b2, b3)),
652652
_ => None
653653
}
@@ -659,7 +659,7 @@ impl Wtf8 {
659659
if len < 3 {
660660
return None
661661
}
662-
match self.bytes.slice_to(3) {
662+
match &self.bytes[..3] {
663663
[0xED, b2 @ 0xB0...0xBF, b3] => Some(decode_surrogate(b2, b3)),
664664
_ => None
665665
}
@@ -768,6 +768,7 @@ impl<'a, S: hash::Hasher + hash::Writer> Hash<S> for Wtf8 {
768768
#[cfg(test)]
769769
mod tests {
770770
use std::borrow::Cow;
771+
use std::string::CowString;
771772
use std::mem::transmute;
772773
use super::*;
773774

@@ -1021,7 +1022,7 @@ mod tests {
10211022
}
10221023

10231024
#[test]
1024-
fn wtf8buf_show() {
1025+
fn wtf8buf_debug() {
10251026
let mut string = Wtf8Buf::from_str("aé 💩");
10261027
string.push(CodePoint::from_u32(0xD800).unwrap());
10271028
assert_eq!(format!("{:?}", string), r#""aé 💩\u{D800}""#);
@@ -1033,7 +1034,7 @@ mod tests {
10331034
}
10341035

10351036
#[test]
1036-
fn wtf8_show() {
1037+
fn wtf8_debug() {
10371038
let mut string = Wtf8Buf::from_str("aé 💩");
10381039
string.push(CodePoint::from_u32(0xD800).unwrap());
10391040
assert_eq!(format!("{:?}", string.as_slice()), r#""aé 💩\u{D800}""#);
@@ -1147,7 +1148,10 @@ mod tests {
11471148
assert_eq!(Wtf8::from_str("aé 💩").to_string_lossy(), Cow::Borrowed("aé 💩"));
11481149
let mut string = Wtf8Buf::from_str("aé 💩");
11491150
string.push(CodePoint::from_u32(0xD800).unwrap());
1150-
assert_eq!(string.to_string_lossy(), Cow::Owned(String::from_str("aé 💩�")));
1151+
assert_eq!(string.to_string_lossy(), {
1152+
let o: CowString = Cow::Owned(String::from_str("aé 💩�"));
1153+
o
1154+
});
11511155
}
11521156

11531157
#[test]

0 commit comments

Comments
 (0)