From fd52e266c6e25999a49c36f17342977b759a2612 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sun, 13 Mar 2022 15:20:03 +0100 Subject: apply clippy suggestions --- planetwars-rules/src/config.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'planetwars-rules/src/config.rs') 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 { 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 { 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)?) } } -- cgit v1.2.3