Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 49d4958

Browse files
committed
Bump to 0.2.7
1 parent 2cb0aae commit 49d4958

File tree

7 files changed

+231
-240
lines changed

7 files changed

+231
-240
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "rustc-serialize"
4-
version = "0.2.6"
4+
version = "0.2.7"
55
authors = ["The Rust Project Developers"]
66
license = "MIT/Apache-2.0"
77
readme = "README.md"

src/base64.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub struct Config {
4646
/// True to pad output with `=` characters
4747
pub pad: bool,
4848
/// `Some(len)` to wrap lines at `len`, `None` to disable line wrapping
49-
pub line_length: Option<uint>
49+
pub line_length: Option<usize>
5050
}
5151

5252
/// Configuration for RFC 4648 standard base64 encoding
@@ -82,7 +82,7 @@ impl ToBase64 for [u8] {
8282
/// # Example
8383
///
8484
/// ```rust
85-
/// # #![allow(staged_unstable)]
85+
/// # #![allow(unstable)]
8686
/// extern crate "rustc-serialize" as rustc_serialize;
8787
/// use rustc_serialize::base64::{ToBase64, STANDARD};
8888
///
@@ -123,10 +123,10 @@ impl ToBase64 for [u8] {
123123
(third as u32);
124124

125125
// This 24-bit number gets separated into four 6-bit numbers.
126-
v.push(bytes[((n >> 18) & 63) as uint]);
127-
v.push(bytes[((n >> 12) & 63) as uint]);
128-
v.push(bytes[((n >> 6 ) & 63) as uint]);
129-
v.push(bytes[(n & 63) as uint]);
126+
v.push(bytes[((n >> 18) & 63) as usize]);
127+
v.push(bytes[((n >> 12) & 63) as usize]);
128+
v.push(bytes[((n >> 6 ) & 63) as usize]);
129+
v.push(bytes[(n & 63) as usize]);
130130

131131
cur_length += 4;
132132
i += 3;
@@ -146,19 +146,19 @@ impl ToBase64 for [u8] {
146146
0 => (),
147147
1 => {
148148
let n = (self[i] as u32) << 16;
149-
v.push(bytes[((n >> 18) & 63) as uint]);
150-
v.push(bytes[((n >> 12) & 63) as uint]);
149+
v.push(bytes[((n >> 18) & 63) as usize]);
150+
v.push(bytes[((n >> 12) & 63) as usize]);
151151
if config.pad {
152152
v.push(b'=');
153153
v.push(b'=');
154154
}
155155
}
156156
2 => {
157157
let n = (self[i] as u32) << 16 |
158-
(self[i + 1u] as u32) << 8;
159-
v.push(bytes[((n >> 18) & 63) as uint]);
160-
v.push(bytes[((n >> 12) & 63) as uint]);
161-
v.push(bytes[((n >> 6 ) & 63) as uint]);
158+
(self[i + 1] as u32) << 8;
159+
v.push(bytes[((n >> 18) & 63) as usize]);
160+
v.push(bytes[((n >> 12) & 63) as usize]);
161+
v.push(bytes[((n >> 6 ) & 63) as usize]);
162162
if config.pad {
163163
v.push(b'=');
164164
}
@@ -181,7 +181,7 @@ pub trait FromBase64 {
181181
#[derive(Copy)]
182182
pub enum FromBase64Error {
183183
/// The input contained a character not part of the base64 format
184-
InvalidBase64Byte(u8, uint),
184+
InvalidBase64Byte(u8, usize),
185185
/// The input had an invalid length
186186
InvalidBase64Length,
187187
}
@@ -221,8 +221,7 @@ impl FromBase64 for str {
221221
/// This converts a string literal to base64 and back.
222222
///
223223
/// ```rust
224-
/// # #![allow(staged_unstable)]
225-
/// # #![allow(staged_experimental)]
224+
/// # #![allow(unstable)]
226225
/// extern crate "rustc-serialize" as rustc_serialize;
227226
/// use rustc_serialize::base64::{ToBase64, FromBase64, STANDARD};
228227
///
@@ -248,7 +247,7 @@ impl FromBase64 for [u8] {
248247
fn from_base64(&self) -> Result<Vec<u8>, FromBase64Error> {
249248
let mut r = Vec::with_capacity(self.len());
250249
let mut buf: u32 = 0;
251-
let mut modulus = 0i;
250+
let mut modulus = 0;
252251

253252
let mut it = self.iter().enumerate();
254253
for (idx, &byte) in it {
@@ -317,7 +316,7 @@ mod tests {
317316

318317
#[test]
319318
fn test_to_base64_crlf_line_break() {
320-
assert!(![0u8; 1000].to_base64(Config {line_length: None, ..STANDARD})
319+
assert!(![08; 1000].to_base64(Config {line_length: None, ..STANDARD})
321320
.contains("\r\n"));
322321
assert_eq!(b"foobar".to_base64(Config {line_length: Some(4),
323322
..STANDARD}),
@@ -326,7 +325,7 @@ mod tests {
326325

327326
#[test]
328327
fn test_to_base64_lf_line_break() {
329-
assert!(![0u8; 1000].to_base64(Config {line_length: None,
328+
assert!(![08; 1000].to_base64(Config {line_length: None,
330329
newline: Newline::LF,
331330
..STANDARD})
332331
.as_slice()
@@ -397,8 +396,8 @@ mod tests {
397396
fn test_base64_random() {
398397
use std::rand::{thread_rng, Rng};
399398

400-
for _ in range(0u, 1000) {
401-
let times = thread_rng().gen_range(1u, 100);
399+
for _ in range(0, 1000) {
400+
let times = thread_rng().gen_range(1, 100);
402401
let v = thread_rng().gen_iter::<u8>().take(times)
403402
.collect::<Vec<_>>();
404403
assert_eq!(v.to_base64(STANDARD)

src/collection_impls.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl<T:Decodable> Decodable for DList<T> {
3434
fn decode<D: Decoder>(d: &mut D) -> Result<DList<T>, D::Error> {
3535
d.read_seq(|d, len| {
3636
let mut list = DList::new();
37-
for i in range(0u, len) {
37+
for i in range(0, len) {
3838
list.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
3939
}
4040
Ok(list)
@@ -57,7 +57,7 @@ impl<T:Decodable> Decodable for RingBuf<T> {
5757
fn decode<D: Decoder>(d: &mut D) -> Result<RingBuf<T>, D::Error> {
5858
d.read_seq(|d, len| {
5959
let mut deque: RingBuf<T> = RingBuf::new();
60-
for i in range(0u, len) {
60+
for i in range(0, len) {
6161
deque.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
6262
}
6363
Ok(deque)
@@ -89,7 +89,7 @@ impl<
8989
fn decode<D: Decoder>(d: &mut D) -> Result<BTreeMap<K, V>, D::Error> {
9090
d.read_map(|d, len| {
9191
let mut map = BTreeMap::new();
92-
for i in range(0u, len) {
92+
for i in range(0, len) {
9393
let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d)));
9494
let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d)));
9595
map.insert(key, val);
@@ -120,7 +120,7 @@ impl<
120120
fn decode<D: Decoder>(d: &mut D) -> Result<BTreeSet<T>, D::Error> {
121121
d.read_seq(|d, len| {
122122
let mut set = BTreeSet::new();
123-
for i in range(0u, len) {
123+
for i in range(0, len) {
124124
set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
125125
}
126126
Ok(set)
@@ -157,7 +157,7 @@ impl<K, V, S> Decodable for HashMap<K, V, S>
157157
d.read_map(|d, len| {
158158
let state = Default::default();
159159
let mut map = HashMap::with_capacity_and_hash_state(len, state);
160-
for i in range(0u, len) {
160+
for i in range(0, len) {
161161
let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d)));
162162
let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d)));
163163
map.insert(key, val);
@@ -193,7 +193,7 @@ impl<T, S> Decodable for HashSet<T, S>
193193
d.read_seq(|d, len| {
194194
let state = Default::default();
195195
let mut set = HashSet::with_capacity_and_hash_state(len, state);
196-
for i in range(0u, len) {
196+
for i in range(0, len) {
197197
set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
198198
}
199199
Ok(set)
@@ -216,7 +216,7 @@ impl<V: Decodable> Decodable for VecMap<V> {
216216
fn decode<D: Decoder>(d: &mut D) -> Result<VecMap<V>, D::Error> {
217217
d.read_map(|d, len| {
218218
let mut map = VecMap::new();
219-
for i in range(0u, len) {
219+
for i in range(0, len) {
220220
let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d)));
221221
let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d)));
222222
map.insert(key, val);

src/hex.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl ToHex for [u8] {
3232
/// # Example
3333
///
3434
/// ```rust
35-
/// # #![allow(staged_unstable)]
35+
/// # #![allow(unstable)]
3636
/// extern crate "rustc-serialize" as rustc_serialize;
3737
/// use rustc_serialize::hex::ToHex;
3838
///
@@ -44,8 +44,8 @@ impl ToHex for [u8] {
4444
fn to_hex(&self) -> String {
4545
let mut v = Vec::with_capacity(self.len() * 2);
4646
for &byte in self.iter() {
47-
v.push(CHARS[(byte >> 4) as uint]);
48-
v.push(CHARS[(byte & 0xf) as uint]);
47+
v.push(CHARS[(byte >> 4) as usize]);
48+
v.push(CHARS[(byte & 0xf) as usize]);
4949
}
5050

5151
unsafe {
@@ -65,7 +65,7 @@ pub trait FromHex {
6565
#[derive(Copy)]
6666
pub enum FromHexError {
6767
/// The input contained a character not part of the hex format
68-
InvalidHexCharacter(char, uint),
68+
InvalidHexCharacter(char, usize),
6969
/// The input had an invalid length
7070
InvalidHexLength,
7171
}
@@ -106,7 +106,7 @@ impl FromHex for str {
106106
/// This converts a string literal to hexadecimal and back.
107107
///
108108
/// ```rust
109-
/// # #![allow(staged_unstable)]
109+
/// # #![allow(unstable)]
110110
/// extern crate "rustc-serialize" as rustc_serialize;
111111
/// use rustc_serialize::hex::{FromHex, ToHex};
112112
///
@@ -122,8 +122,8 @@ impl FromHex for str {
122122
fn from_hex(&self) -> Result<Vec<u8>, FromHexError> {
123123
// This may be an overestimate if there is any whitespace
124124
let mut b = Vec::with_capacity(self.len() / 2);
125-
let mut modulus = 0i;
126-
let mut buf = 0u8;
125+
let mut modulus = 0;
126+
let mut buf = 08;
127127

128128
for (idx, byte) in self.bytes().enumerate() {
129129
buf <<= 4;
@@ -191,20 +191,18 @@ mod tests {
191191

192192
#[test]
193193
pub fn test_to_hex_all_bytes() {
194-
for i in range(0u, 256) {
195-
assert_eq!([i as u8].to_hex(), format!("{:02x}", i as uint));
194+
for i in range(0, 256) {
195+
assert_eq!([i as u8].to_hex(), format!("{:02x}", i));
196196
}
197197
}
198198

199199
#[test]
200200
pub fn test_from_hex_all_bytes() {
201-
for i in range(0u, 256) {
201+
for i in range(0, 256) {
202202
let ii: &[u8] = &[i as u8];
203-
assert_eq!(format!("{:02x}", i as uint).from_hex()
204-
.unwrap(),
203+
assert_eq!(format!("{:02x}", i).from_hex().unwrap(),
205204
ii);
206-
assert_eq!(format!("{:02X}", i as uint).from_hex()
207-
.unwrap(),
205+
assert_eq!(format!("{:02X}", i).from_hex().unwrap(),
208206
ii);
209207
}
210208
}

0 commit comments

Comments
 (0)