Skip to content

Commit

Permalink
Misc clippy improvements
Browse files Browse the repository at this point in the history
- to_string -> to_owned
- Eliminate redundant closures and bindings
- More easily clone a vector
  • Loading branch information
ogham committed Nov 24, 2015
1 parent 34c9883 commit 54c7263
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ impl<'table> Iterator for Iter<'table> {
};

// Move the strings out into an (automatically-sorted) vector.
let values = self.structure.mappings[key].iter()
.map(|&s| s)
.collect();
let values = self.structure.mappings[key].iter().cloned().collect();

return Some(TableStructureEntry {
name: key,
Expand Down
14 changes: 7 additions & 7 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Table {
let t = (start_time.unwrap(), FixedTimespan {
utc_offset: utc_offset,
dst_offset: dst_offset,
name: start_zone_id.clone().unwrap_or("".to_string()),
name: start_zone_id.clone().unwrap_or("".to_owned()),
});
transitions.push(t);
insert_start_transition = false;
Expand All @@ -140,7 +140,7 @@ impl Table {
first_transition = Some(FixedTimespan {
utc_offset: utc_offset,
dst_offset: dst_offset,
name: start_zone_id.clone().unwrap_or("".to_string()),
name: start_zone_id.clone().unwrap_or("".to_owned()),
});
}
},
Expand All @@ -153,7 +153,7 @@ impl Table {
let t = (start_time.unwrap(), FixedTimespan {
utc_offset: utc_offset,
dst_offset: dst_offset,
name: start_zone_id.clone().unwrap_or("".to_string()),
name: start_zone_id.clone().unwrap_or("".to_owned()),
});
transitions.push(t);
insert_start_transition = false;
Expand All @@ -162,7 +162,7 @@ impl Table {
first_transition = Some(FixedTimespan {
utc_offset: utc_offset,
dst_offset: dst_offset,
name: start_zone_id.clone().unwrap_or("".to_string()),
name: start_zone_id.clone().unwrap_or("".to_owned()),
});
}
},
Expand Down Expand Up @@ -517,7 +517,7 @@ impl TableBuilder {
Entry::Vacant(e) => e.insert(Vec::new()),
};

let _ = zoneset.push(zone_line.info.into());
zoneset.push(zone_line.info.into());
self.current_zoneset_name = Some(zone_line.name.to_owned());
Ok(())
}
Expand All @@ -532,7 +532,7 @@ impl TableBuilder {
None => return Err(Error::SurpriseContinuationLine),
};

let _ = zoneset.push(continuation_line.into());
zoneset.push(continuation_line.into());
Ok(())
}

Expand All @@ -541,7 +541,7 @@ impl TableBuilder {
pub fn add_rule_line(&mut self, rule_line: line::Rule) -> Result<(), Error> {
let ruleset = self.table.rulesets
.entry(rule_line.name.to_owned())
.or_insert_with(|| Vec::new());
.or_insert_with(Vec::new);

ruleset.push(rule_line.into());
self.current_zoneset_name = None;
Expand Down

0 comments on commit 54c7263

Please sign in to comment.