Auto merge of #21613 - alfie:suffix-small, r=alexcrichton

This commit is contained in:
bors 2015-02-03 07:59:04 +00:00
commit 336c8d2e9c
35 changed files with 182 additions and 182 deletions

View file

@ -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 0u..len {
for i in 0..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 0u..len {
for i in 0..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 0u..len {
for i in 0..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 0u..len {
for i in 0..len {
set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
}
Ok(set)
@ -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 0u..len {
for i in 0..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 0u..len {
for i in 0..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 0u..len {
for i in 0..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);

View file

@ -185,14 +185,14 @@ mod tests {
#[test]
pub fn test_to_hex_all_bytes() {
for i in 0u..256 {
for i in 0..256 {
assert_eq!([i as u8].to_hex(), format!("{:02x}", i as uint));
}
}
#[test]
pub fn test_from_hex_all_bytes() {
for i in 0u..256 {
for i in 0..256 {
let ii: &[u8] = &[i as u8];
assert_eq!(format!("{:02x}", i as uint).from_hex()
.unwrap(),

View file

@ -457,8 +457,8 @@ fn spaces(wr: &mut fmt::Writer, mut n: uint) -> EncodeResult {
fn fmt_number_or_null(v: f64) -> string::String {
match v.classify() {
Fp::Nan | Fp::Infinite => string::String::from_str("null"),
_ if v.fract() != 0f64 => f64::to_str_digits(v, 6u),
_ => f64::to_str_digits(v, 6u) + ".0",
_ if v.fract() != 0f64 => f64::to_str_digits(v, 6),
_ => f64::to_str_digits(v, 6) + ".0",
}
}
@ -1474,10 +1474,10 @@ impl<T: Iterator<Item=char>> Parser<T> {
self.ch = self.rdr.next();
if self.ch_is('\n') {
self.line += 1u;
self.col = 1u;
self.line += 1;
self.col = 1;
} else {
self.col += 1u;
self.col += 1;
}
}
@ -1614,7 +1614,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
fn parse_exponent(&mut self, mut res: f64) -> Result<f64, ParserError> {
self.bump();
let mut exp = 0u;
let mut exp = 0;
let mut neg_exp = false;
if self.ch_is('+') {
@ -1652,7 +1652,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
}
fn decode_hex_escape(&mut self) -> Result<u16, ParserError> {
let mut i = 0u;
let mut i = 0;
let mut n = 0u16;
while i < 4 && !self.eof() {
self.bump();
@ -1667,7 +1667,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
_ => return self.error(InvalidEscape)
};
i += 1u;
i += 1;
}
// Error out if we didn't parse 4 digits.
@ -2638,7 +2638,7 @@ mod tests {
fn test_decode_option_some() {
let s = "{ \"opt\": 10 }";
let obj: OptionData = super::decode(s).unwrap();
assert_eq!(obj, OptionData { opt: Some(10u) });
assert_eq!(obj, OptionData { opt: Some(10) });
}
#[test]
@ -3092,10 +3092,10 @@ mod tests {
#[test]
fn test_decode_tuple() {
let t: (uint, uint, uint) = super::decode("[1, 2, 3]").unwrap();
assert_eq!(t, (1u, 2, 3));
assert_eq!(t, (1, 2, 3));
let t: (uint, string::String) = super::decode("[1, \"two\"]").unwrap();
assert_eq!(t, (1u, "two".to_string()));
assert_eq!(t, (1, "two".to_string()));
}
#[test]
@ -3228,7 +3228,7 @@ mod tests {
#[test]
fn test_multiline_errors() {
assert_eq!(from_str("{\n \"foo\":\n \"bar\""),
Err(SyntaxError(EOFWhileParsingObject, 3u, 8u)));
Err(SyntaxError(EOFWhileParsingObject, 3, 8)));
}
#[derive(RustcDecodable)]
@ -3512,7 +3512,7 @@ mod tests {
}
// Test up to 4 spaces of indents (more?)
for i in 0..4u {
for i in 0..4 {
let mut writer = Vec::new();
write!(&mut writer, "{}",
super::as_pretty_json(&json).indent(i)).unwrap();
@ -3924,22 +3924,22 @@ mod tests {
assert_eq!(false.to_json(), Boolean(false));
assert_eq!("abc".to_json(), String("abc".to_string()));
assert_eq!("abc".to_string().to_json(), String("abc".to_string()));
assert_eq!((1u, 2u).to_json(), array2);
assert_eq!((1u, 2u, 3u).to_json(), array3);
assert_eq!([1u, 2].to_json(), array2);
assert_eq!((&[1u, 2, 3]).to_json(), array3);
assert_eq!((vec![1u, 2]).to_json(), array2);
assert_eq!(vec!(1u, 2, 3).to_json(), array3);
assert_eq!((1us, 2us).to_json(), array2);
assert_eq!((1us, 2us, 3us).to_json(), array3);
assert_eq!([1us, 2us].to_json(), array2);
assert_eq!((&[1us, 2us, 3us]).to_json(), array3);
assert_eq!((vec![1us, 2us]).to_json(), array2);
assert_eq!(vec!(1us, 2us, 3us).to_json(), array3);
let mut tree_map = BTreeMap::new();
tree_map.insert("a".to_string(), 1u);
tree_map.insert("a".to_string(), 1us);
tree_map.insert("b".to_string(), 2);
assert_eq!(tree_map.to_json(), object);
let mut hash_map = HashMap::new();
hash_map.insert("a".to_string(), 1u);
hash_map.insert("a".to_string(), 1us);
hash_map.insert("b".to_string(), 2);
assert_eq!(hash_map.to_json(), object);
assert_eq!(Some(15).to_json(), I64(15));
assert_eq!(Some(15u).to_json(), U64(15));
assert_eq!(Some(15us).to_json(), U64(15));
assert_eq!(None::<int>.to_json(), Null);
}

View file

@ -498,7 +498,7 @@ macro_rules! peel {
/// Evaluates to the number of identifiers passed to it, for example: `count_idents!(a, b, c) == 3
macro_rules! count_idents {
() => { 0u };
() => { 0 };
($_i:ident, $($rest:ident,)*) => { 1 + count_idents!($($rest,)*) }
}