Minor fix, add unused_must_use as deny linter
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2023-04-21 09:39:20 +02:00
parent db88d31394
commit a6f4b1d5c5
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 7 additions and 14 deletions

View File

@ -200,10 +200,8 @@ impl Battle {
for (side_index, side) in self.sides.iter().enumerate() { for (side_index, side) in self.sides.iter().enumerate() {
// If any side has fled, the battle end. // If any side has fled, the battle end.
if side.has_fled_battle() { if side.has_fled_battle() {
let _w = self.result.write(); let mut w = self.result.write();
unsafe { *w = BattleResult::Inconclusive;
self.result.data_ptr().replace(BattleResult::Inconclusive);
}
self.has_ended.store(true, Ordering::SeqCst); self.has_ended.store(true, Ordering::SeqCst);
return Ok(()); return Ok(());
} }
@ -219,19 +217,13 @@ impl Battle {
} }
// Everyone died :( // Everyone died :(
if !surviving_side_exists { if !surviving_side_exists {
let _w = self.result.write(); let mut w = self.result.write();
unsafe { *w = BattleResult::Inconclusive;
self.result.data_ptr().replace(BattleResult::Inconclusive);
}
} }
// Someone survived, they won! // Someone survived, they won!
else { else {
let _w = self.result.write(); let mut w = self.result.write();
unsafe { *w = BattleResult::Conclusive(winning_side.ok_or(anyhow!("Winning side was not set"))?);
self.result.data_ptr().replace(BattleResult::Conclusive(
winning_side.ok_or(anyhow!("Winning side was not set"))?,
));
}
} }
self.has_ended.store(true, Ordering::SeqCst); self.has_ended.store(true, Ordering::SeqCst);
Ok(()) Ok(())

View File

@ -14,6 +14,7 @@
#![deny(clippy::string_slice)] #![deny(clippy::string_slice)]
#![deny(clippy::exit)] #![deny(clippy::exit)]
#![deny(clippy::panic)] #![deny(clippy::panic)]
#![deny(unused_must_use)]
// Features // Features
#![feature(test)] #![feature(test)]
#![feature(const_option)] #![feature(const_option)]