Use the IntoIterator trait in for loops
This commit is contained in:
parent
cb8492d74b
commit
79ff9fdafa
@ -283,7 +283,7 @@ mod decoder {
|
||||
match self.stack.pop() {
|
||||
Some(MapState(map)) => {
|
||||
let len = map.len();
|
||||
for (key, value) in map.into_iter() {
|
||||
for (key, value) in map {
|
||||
match value {
|
||||
Some(c) => {
|
||||
self.stack.push(CharState(c));
|
||||
@ -404,7 +404,7 @@ mod deserializer {
|
||||
Some(MapState(value)) => {
|
||||
self.stack.push(EndState);
|
||||
let len = value.len();
|
||||
for (key, value) in value.into_iter() {
|
||||
for (key, value) in value {
|
||||
match value {
|
||||
Some(c) => {
|
||||
self.stack.push(CharState(c));
|
||||
|
@ -547,7 +547,7 @@ mod tests {
|
||||
fn test_parse_ok<'a, T>(errors: Vec<(&'a str, T)>)
|
||||
where T: PartialEq + Debug + Deserialize,
|
||||
{
|
||||
for (s, value) in errors.into_iter() {
|
||||
for (s, value) in errors {
|
||||
let v: Result<T, Error> = from_str(s);
|
||||
assert_eq!(v, Ok(value));
|
||||
|
||||
@ -561,7 +561,7 @@ mod tests {
|
||||
fn test_parse_err<'a, T>(errors: Vec<(&'a str, Error)>)
|
||||
where T: PartialEq + Debug + Deserialize
|
||||
{
|
||||
for (s, err) in errors.into_iter() {
|
||||
for (s, err) in errors {
|
||||
let v: Result<T, Error> = from_str(s);
|
||||
assert_eq!(v, Err(err));
|
||||
}
|
||||
|
@ -427,7 +427,7 @@ mod tests {
|
||||
fn test_encode_ok<
|
||||
T: PartialEq + Debug + ToJson + ser::Serialize<super::Serializer<Vec<u8>>, old_io::IoError>
|
||||
>(errors: &[(T, &str)]) {
|
||||
for &(ref value, out) in errors.iter() {
|
||||
for &(ref value, out) in errors {
|
||||
let out = out.to_string();
|
||||
|
||||
let s = super::to_string(value).unwrap();
|
||||
@ -441,7 +441,7 @@ mod tests {
|
||||
fn test_pretty_encode_ok<
|
||||
T: PartialEq + Debug + ToJson + ser::Serialize<super::PrettySerializer<Vec<u8>>, old_io::IoError>
|
||||
>(errors: &[(T, &str)]) {
|
||||
for &(ref value, out) in errors.iter() {
|
||||
for &(ref value, out) in errors {
|
||||
let out = out.to_string();
|
||||
|
||||
let s = super::to_pretty_string(value).unwrap();
|
||||
@ -778,7 +778,7 @@ mod tests {
|
||||
'a,
|
||||
T: Debug + de::Deserialize<Parser<str::Bytes<'a>>, Error>
|
||||
>(errors: &[(&'a str, Error)]) {
|
||||
for &(s, ref err) in errors.iter() {
|
||||
for &(s, ref err) in errors {
|
||||
let v: Result<T, Error> = from_str(s);
|
||||
assert_eq!(v.unwrap_err(), *err);
|
||||
}
|
||||
@ -788,7 +788,7 @@ mod tests {
|
||||
'a,
|
||||
T: PartialEq + Debug + ToJson + de::Deserialize<Parser<str::Bytes<'a>>, Error>
|
||||
>(errors: &[(&'a str, T)]) {
|
||||
for &(s, ref value) in errors.iter() {
|
||||
for &(s, ref value) in errors {
|
||||
let v: T = from_str(s).unwrap();
|
||||
assert_eq!(v, *value);
|
||||
|
||||
@ -800,7 +800,7 @@ mod tests {
|
||||
fn test_json_deserialize_ok<
|
||||
T: PartialEq + Debug + ToJson + de::Deserialize<value::Deserializer, Error>
|
||||
>(errors: &[T]) {
|
||||
for value in errors.iter() {
|
||||
for value in errors {
|
||||
let v: T = from_json(value.to_json()).unwrap();
|
||||
assert_eq!(v, *value);
|
||||
|
||||
|
@ -60,7 +60,7 @@ impl Value {
|
||||
/// Otherwise, it will return the Json value associated with the final key.
|
||||
pub fn find_path<'a>(&'a self, keys: &[&String]) -> Option<&'a Value>{
|
||||
let mut target = self;
|
||||
for key in keys.iter() {
|
||||
for key in keys {
|
||||
match target.find(*key) {
|
||||
Some(t) => { target = t; },
|
||||
None => return None
|
||||
@ -79,7 +79,7 @@ impl Value {
|
||||
Some(json_value) => Some(json_value),
|
||||
None => {
|
||||
let mut value : Option<&'a Value> = None;
|
||||
for (_, v) in map.iter() {
|
||||
for (_, v) in map {
|
||||
value = v.search(key);
|
||||
if value.is_some() {
|
||||
break;
|
||||
@ -643,7 +643,7 @@ impl<A:ToJson> ToJson for Vec<A> {
|
||||
impl<A:ToJson> ToJson for BTreeMap<String, A> {
|
||||
fn to_json(&self) -> Value {
|
||||
let mut d = BTreeMap::new();
|
||||
for (key, value) in self.iter() {
|
||||
for (key, value) in self {
|
||||
d.insert((*key).clone(), value.to_json());
|
||||
}
|
||||
Value::Object(d)
|
||||
@ -653,7 +653,7 @@ impl<A:ToJson> ToJson for BTreeMap<String, A> {
|
||||
impl<A:ToJson> ToJson for HashMap<String, A> {
|
||||
fn to_json(&self) -> Value {
|
||||
let mut d = BTreeMap::new();
|
||||
for (key, value) in self.iter() {
|
||||
for (key, value) in self {
|
||||
d.insert((*key).clone(), value.to_json());
|
||||
}
|
||||
Value::Object(d)
|
||||
|
Loading…
Reference in New Issue
Block a user