about summary refs log tree commit diff
path: root/src/libserialize
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-01-29 16:28:52 +0000
committerbors <bors@rust-lang.org>2015-01-29 16:28:52 +0000
commit265a23320dbeaeca45b889cfea684d71dec1b8e6 (patch)
tree36775481b19e207f139d108aeb88875b695de181 /src/libserialize
parent3d6f5100aff24aa97275dc92ade728caac605560 (diff)
parenta6f9180fd61f509ebc6d666eda3f6bb42dd02573 (diff)
downloadrust-265a23320dbeaeca45b889cfea684d71dec1b8e6.tar.gz
rust-265a23320dbeaeca45b889cfea684d71dec1b8e6.zip
Auto merge of #21677 - japaric:no-range, r=alexcrichton
Note: Do not merge until we get a newer snapshot that includes #21374

There was some type inference fallout (see 4th commit) because type inference with `a..b` is not as good as with `range(a, b)` (see #21672).

r? @alexcrichton 
Diffstat (limited to 'src/libserialize')
-rw-r--r--src/libserialize/collection_impls.rs16
-rw-r--r--src/libserialize/hex.rs6
-rw-r--r--src/libserialize/json.rs36
-rw-r--r--src/libserialize/serialize.rs4
4 files changed, 31 insertions, 31 deletions
diff --git a/src/libserialize/collection_impls.rs b/src/libserialize/collection_impls.rs
index 10698259739..8b39d91ffae 100644
--- a/src/libserialize/collection_impls.rs
+++ b/src/libserialize/collection_impls.rs
@@ -36,7 +36,7 @@ impl<T:Decodable> Decodable for DList<T> {
     fn decode<D: Decoder>(d: &mut D) -> Result<DList<T>, D::Error> {
         d.read_seq(|d, len| {
             let mut list = DList::new();
-            for i in range(0u, len) {
+            for i in 0u..len {
                 list.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
             }
             Ok(list)
@@ -59,7 +59,7 @@ impl<T:Decodable> Decodable for RingBuf<T> {
     fn decode<D: Decoder>(d: &mut D) -> Result<RingBuf<T>, D::Error> {
         d.read_seq(|d, len| {
             let mut deque: RingBuf<T> = RingBuf::new();
-            for i in range(0u, len) {
+            for i in 0u..len {
                 deque.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
             }
             Ok(deque)
@@ -91,7 +91,7 @@ impl<
     fn decode<D: Decoder>(d: &mut D) -> Result<BTreeMap<K, V>, D::Error> {
         d.read_map(|d, len| {
             let mut map = BTreeMap::new();
-            for i in range(0u, len) {
+            for i in 0u..len {
                 let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d)));
                 let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d)));
                 map.insert(key, val);
@@ -122,7 +122,7 @@ impl<
     fn decode<D: Decoder>(d: &mut D) -> Result<BTreeSet<T>, D::Error> {
         d.read_seq(|d, len| {
             let mut set = BTreeSet::new();
-            for i in range(0u, len) {
+            for i in 0u..len {
                 set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
             }
             Ok(set)
@@ -148,7 +148,7 @@ impl<
     fn decode<D: Decoder>(d: &mut D) -> Result<EnumSet<T>, D::Error> {
         let bits = try!(d.read_uint());
         let mut set = EnumSet::new();
-        for bit in range(0, uint::BITS) {
+        for bit in 0..uint::BITS {
             if bits & (1 << bit) != 0 {
                 set.insert(CLike::from_uint(1 << bit));
             }
@@ -186,7 +186,7 @@ impl<K, V, S> Decodable for HashMap<K, V, S>
         d.read_map(|d, len| {
             let state = Default::default();
             let mut map = HashMap::with_capacity_and_hash_state(len, state);
-            for i in range(0u, len) {
+            for i in 0u..len {
                 let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d)));
                 let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d)));
                 map.insert(key, val);
@@ -222,7 +222,7 @@ impl<T, S> Decodable for HashSet<T, S>
         d.read_seq(|d, len| {
             let state = Default::default();
             let mut set = HashSet::with_capacity_and_hash_state(len, state);
-            for i in range(0u, len) {
+            for i in 0u..len {
                 set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
             }
             Ok(set)
@@ -246,7 +246,7 @@ impl<V: Decodable> Decodable for VecMap<V> {
     fn decode<D: Decoder>(d: &mut D) -> Result<VecMap<V>, D::Error> {
         d.read_map(|d, len| {
             let mut map = VecMap::new();
-            for i in range(0u, len) {
+            for i in 0u..len {
                 let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d)));
                 let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d)));
                 map.insert(key, val);
diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs
index 33c5d7402f0..d3c2ffa9544 100644
--- a/src/libserialize/hex.rs
+++ b/src/libserialize/hex.rs
@@ -61,7 +61,7 @@ pub trait FromHex {
 }
 
 /// Errors that can occur when decoding a hex encoded string
-#[derive(Copy, Show)]
+#[derive(Copy, Debug)]
 pub enum FromHexError {
     /// The input contained a character not part of the hex format
     InvalidHexCharacter(char, uint),
@@ -185,14 +185,14 @@ mod tests {
 
     #[test]
     pub fn test_to_hex_all_bytes() {
-        for i in range(0u, 256) {
+        for i in 0u..256 {
             assert_eq!([i as u8].to_hex(), format!("{:02x}", i as uint));
         }
     }
 
     #[test]
     pub fn test_from_hex_all_bytes() {
-        for i in range(0u, 256) {
+        for i in 0u..256 {
             let ii: &[u8] = &[i as u8];
             assert_eq!(format!("{:02x}", i as uint).from_hex()
                                                    .unwrap(),
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index 9a14e738801..2e7a6fd4923 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -214,7 +214,7 @@ use unicode::str::Utf16Item;
 use Encodable;
 
 /// Represents a json value
-#[derive(Clone, PartialEq, PartialOrd, Show)]
+#[derive(Clone, PartialEq, PartialOrd, Debug)]
 pub enum Json {
     I64(i64),
     U64(u64),
@@ -235,7 +235,7 @@ pub struct AsJson<'a, T: 'a> { inner: &'a T }
 pub struct AsPrettyJson<'a, T: 'a> { inner: &'a T, indent: Option<uint> }
 
 /// The errors that can arise while parsing a JSON stream.
-#[derive(Clone, Copy, PartialEq, Show)]
+#[derive(Clone, Copy, PartialEq, Debug)]
 pub enum ErrorCode {
     InvalidSyntax,
     InvalidNumber,
@@ -256,7 +256,7 @@ pub enum ErrorCode {
     NotUtf8,
 }
 
-#[derive(Clone, Copy, PartialEq, Show)]
+#[derive(Clone, Copy, PartialEq, Debug)]
 pub enum ParserError {
     /// msg, line, col
     SyntaxError(ErrorCode, uint, uint),
@@ -266,7 +266,7 @@ pub enum ParserError {
 // Builder and Parser have the same errors.
 pub type BuilderError = ParserError;
 
-#[derive(Clone, PartialEq, Show)]
+#[derive(Clone, PartialEq, Debug)]
 pub enum DecoderError {
     ParseError(ParserError),
     ExpectedError(string::String, string::String),
@@ -275,7 +275,7 @@ pub enum DecoderError {
     ApplicationError(string::String)
 }
 
-#[derive(Copy, Show)]
+#[derive(Copy, Debug)]
 pub enum EncoderError {
     FmtError(fmt::Error),
     BadHashmapKey,
@@ -1237,7 +1237,7 @@ impl Index<uint> for Json {
 }
 
 /// The output of the streaming parser.
-#[derive(PartialEq, Clone, Show)]
+#[derive(PartialEq, Clone, Debug)]
 pub enum JsonEvent {
     ObjectStart,
     ObjectEnd,
@@ -1252,7 +1252,7 @@ pub enum JsonEvent {
     Error(ParserError),
 }
 
-#[derive(PartialEq, Show)]
+#[derive(PartialEq, Debug)]
 enum ParserState {
     // Parse a value in an array, true means first element.
     ParseArray(bool),
@@ -1282,7 +1282,7 @@ pub struct Stack {
 /// For example, StackElement::Key("foo"), StackElement::Key("bar"),
 /// StackElement::Index(3) and StackElement::Key("x") are the
 /// StackElements compositing the stack that represents foo.bar[3].x
-#[derive(PartialEq, Clone, Show)]
+#[derive(PartialEq, Clone, Debug)]
 pub enum StackElement<'l> {
     Index(u32),
     Key(&'l str),
@@ -1290,7 +1290,7 @@ pub enum StackElement<'l> {
 
 // Internally, Key elements are stored as indices in a buffer to avoid
 // allocating a string for every member of an object.
-#[derive(PartialEq, Clone, Show)]
+#[derive(PartialEq, Clone, Debug)]
 enum InternalStackElement {
     InternalIndex(u32),
     InternalKey(u16, u16), // start, size
@@ -1324,7 +1324,7 @@ impl Stack {
     /// Compares this stack with an array of StackElements.
     pub fn is_equal_to(&self, rhs: &[StackElement]) -> bool {
         if self.stack.len() != rhs.len() { return false; }
-        for i in range(0, rhs.len()) {
+        for i in 0..rhs.len() {
             if self.get(i) != rhs[i] { return false; }
         }
         return true;
@@ -1334,7 +1334,7 @@ impl Stack {
     /// the ones passed as parameter.
     pub fn starts_with(&self, rhs: &[StackElement]) -> bool {
         if self.stack.len() < rhs.len() { return false; }
-        for i in range(0, rhs.len()) {
+        for i in 0..rhs.len() {
             if self.get(i) != rhs[i] { return false; }
         }
         return true;
@@ -1345,7 +1345,7 @@ impl Stack {
     pub fn ends_with(&self, rhs: &[StackElement]) -> bool {
         if self.stack.len() < rhs.len() { return false; }
         let offset = self.stack.len() - rhs.len();
-        for i in range(0, rhs.len()) {
+        for i in 0..rhs.len() {
             if self.get(i + offset) != rhs[i] { return false; }
         }
         return true;
@@ -2621,7 +2621,7 @@ mod tests {
     use std::num::Float;
     use std::string;
 
-    #[derive(RustcDecodable, Eq, PartialEq, Show)]
+    #[derive(RustcDecodable, Eq, PartialEq, Debug)]
     struct OptionData {
         opt: Option<uint>,
     }
@@ -2648,20 +2648,20 @@ mod tests {
                                 ExpectedError("Number".to_string(), "false".to_string()));
     }
 
-    #[derive(PartialEq, RustcEncodable, RustcDecodable, Show)]
+    #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)]
     enum Animal {
         Dog,
         Frog(string::String, int)
     }
 
-    #[derive(PartialEq, RustcEncodable, RustcDecodable, Show)]
+    #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)]
     struct Inner {
         a: (),
         b: uint,
         c: Vec<string::String>,
     }
 
-    #[derive(PartialEq, RustcEncodable, RustcDecodable, Show)]
+    #[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)]
     struct Outer {
         inner: Vec<Inner>,
     }
@@ -3511,7 +3511,7 @@ mod tests {
         }
 
         // Test up to 4 spaces of indents (more?)
-        for i in range(0, 4u) {
+        for i in 0..4u {
             let mut writer = Vec::new();
             write!(&mut writer, "{}",
                    super::as_pretty_json(&json).indent(i)).unwrap();
@@ -3997,7 +3997,7 @@ mod tests {
 
     fn big_json() -> string::String {
         let mut src = "[\n".to_string();
-        for _ in range(0i, 500) {
+        for _ in 0i..500 {
             src.push_str(r#"{ "a": true, "b": null, "c":3.1415, "d": "Hello world", "e": \
                             [1,2,3]},"#);
         }
diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs
index e93d71a9dff..f963d0ce813 100644
--- a/src/libserialize/serialize.rs
+++ b/src/libserialize/serialize.rs
@@ -461,7 +461,7 @@ impl<T:Decodable> Decodable for Vec<T> {
     fn decode<D: Decoder>(d: &mut D) -> Result<Vec<T>, D::Error> {
         d.read_seq(|d, len| {
             let mut v = Vec::with_capacity(len);
-            for i in range(0, len) {
+            for i in 0..len {
                 v.push(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
             }
             Ok(v)
@@ -641,7 +641,7 @@ impl<D: Decoder> DecoderHelpers for D {
     {
         self.read_seq(|this, len| {
             let mut v = Vec::with_capacity(len);
-            for i in range(0, len) {
+            for i in 0..len {
                 v.push(try!(this.read_seq_elt(i, |this| f(this))));
             }
             Ok(v)