Use idiomatic enumerate method on interators instead of iterating over indices

Signed-off-by: Victor Porof <vporof@mozilla.com>
This commit is contained in:
Victor Porof 2017-02-01 12:15:15 +01:00
parent 4b2c7870c0
commit 4e9e8ed837

View file

@ -926,9 +926,7 @@ fn test_is_and_as_type_helper_functions() {
])), ])),
]; ];
for i in 0..values.len() { for (i, value) in values.iter().enumerate() {
let value = &values[i];
let is_result = [ let is_result = [
value.is_nil(), value.is_nil(),
value.is_boolean(), value.is_boolean(),
@ -946,12 +944,17 @@ fn test_is_and_as_type_helper_functions() {
value.is_map(), value.is_map(),
]; ];
for j in 0..values.len() { assert_eq!(values.len(), is_result.len());
assert_eq!(j == i, is_result[j]);
for (j, result) in is_result.iter().enumerate() {
assert_eq!(j == i, *result);
} }
if i == 0 { assert_eq!(value.as_nil().unwrap(), ()) } if i == 0 {
else { assert!(!value.as_nil().is_some()) } assert_eq!(value.as_nil().unwrap(), ())
} else {
assert!(!value.as_nil().is_some())
}
def_test_as_type!(value, as_boolean, i == 1, false); def_test_as_type!(value, as_boolean, i == 1, false);
def_test_as_type!(value, as_integer, i == 2, 1i64); def_test_as_type!(value, as_integer, i == 2, 1i64);