aboutsummaryrefslogtreecommitdiff
path: root/planetwars-rules/src/config.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-03-13 15:20:03 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2022-03-13 15:20:03 +0100
commitfd52e266c6e25999a49c36f17342977b759a2612 (patch)
tree9c727cac949c9698343d003ee87cfe73c6c6204a /planetwars-rules/src/config.rs
parentf7655005ff099e8314ecd31e95b26ad74d4efd02 (diff)
downloadplanetwars.dev-fd52e266c6e25999a49c36f17342977b759a2612.tar.xz
planetwars.dev-fd52e266c6e25999a49c36f17342977b759a2612.zip
apply clippy suggestions
Diffstat (limited to 'planetwars-rules/src/config.rs')
-rw-r--r--planetwars-rules/src/config.rs20
1 files changed, 9 insertions, 11 deletions
diff --git a/planetwars-rules/src/config.rs b/planetwars-rules/src/config.rs
index 57c77eb..14a4ac2 100644
--- a/planetwars-rules/src/config.rs
+++ b/planetwars-rules/src/config.rs
@@ -25,8 +25,8 @@ impl Config {
.collect();
PwState {
- players: players,
- planets: planets,
+ players,
+ planets,
expeditions: Vec::new(),
expedition_num: 0,
turn_num: 0,
@@ -37,8 +37,7 @@ impl Config {
fn load_map(&self, num_players: usize) -> Vec<Planet> {
let map = self.read_map().expect("[PLANET_WARS] reading map failed");
- return map
- .planets
+ map.planets
.into_iter()
.enumerate()
.map(|(num, planet)| {
@@ -55,27 +54,26 @@ impl Config {
});
if planet.ship_count > 0 {
fleets.push(Fleet {
- owner: owner,
+ owner,
ship_count: planet.ship_count,
});
}
- return Planet {
+ Planet {
id: num,
name: planet.name,
x: planet.x,
y: planet.y,
- fleets: fleets,
- };
+ fleets,
+ }
})
- .collect();
+ .collect()
}
fn read_map(&self) -> io::Result<Map> {
let mut file = File::open(&self.map_file)?;
let mut buf = String::new();
file.read_to_string(&mut buf)?;
- let map = serde_json::from_str(&buf)?;
- return Ok(map);
+ Ok(serde_json::from_str(&buf)?)
}
}