cargo clippy --fix
This commit is contained in:
parent
16c78c81ae
commit
bb356427df
@ -30,7 +30,7 @@ use crate::{
|
||||
// info is called when you create your Battlesnake on play.battlesnake.com
|
||||
// and controls your Battlesnake's appearance
|
||||
// TIP: If you open your Battlesnake URL in a browser you should see this data
|
||||
pub fn info() -> Value {
|
||||
#[must_use] pub fn info() -> Value {
|
||||
info!("INFO");
|
||||
|
||||
json!({
|
||||
|
@ -7,7 +7,7 @@ use rocket::{
|
||||
get,
|
||||
http::Status,
|
||||
launch, post, routes,
|
||||
serde::{json::Json, Deserialize},
|
||||
serde::json::Json,
|
||||
tokio::task,
|
||||
};
|
||||
use serde_json::Value;
|
||||
|
@ -14,7 +14,7 @@ pub struct SnakeToken {
|
||||
}
|
||||
|
||||
impl SnakeToken {
|
||||
pub fn from_board(board: &crate::Board) -> BTreeMap<String, Self> {
|
||||
#[must_use] pub fn from_board(board: &crate::Board) -> BTreeMap<String, Self> {
|
||||
board
|
||||
.snakes
|
||||
.iter()
|
||||
@ -52,7 +52,7 @@ pub struct Board {
|
||||
}
|
||||
|
||||
impl Board {
|
||||
pub fn from_game_board(
|
||||
#[must_use] pub fn from_game_board(
|
||||
board: &crate::Board,
|
||||
token_map: &BTreeMap<String, SnakeToken>,
|
||||
turn: i32,
|
||||
@ -86,16 +86,16 @@ impl Board {
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn turn(&self) -> i32 {
|
||||
#[must_use] pub const fn turn(&self) -> i32 {
|
||||
self.turn
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_sign_loss)]
|
||||
pub const fn spaces(&self) -> usize {
|
||||
#[must_use] pub const fn spaces(&self) -> usize {
|
||||
self.height as usize * self.width as usize
|
||||
}
|
||||
|
||||
pub fn alive_snakes(&self) -> usize {
|
||||
#[must_use] pub fn alive_snakes(&self) -> usize {
|
||||
self.snakes.len()
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ impl Board {
|
||||
self.snakes.keys().copied()
|
||||
}
|
||||
|
||||
pub fn snake_length(&self, token: SnakeToken) -> Option<usize> {
|
||||
#[must_use] pub fn snake_length(&self, token: SnakeToken) -> Option<usize> {
|
||||
self.snakes.get(&token).map(|snake| snake.body.len())
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ impl Board {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn possible_actions(&self) -> BTreeMap<SnakeToken, BTreeSet<Direction>> {
|
||||
#[must_use] pub fn possible_actions(&self) -> BTreeMap<SnakeToken, BTreeSet<Direction>> {
|
||||
let mut actions: BTreeMap<_, BTreeSet<_>> = self
|
||||
.snakes
|
||||
.keys()
|
||||
@ -272,7 +272,7 @@ pub struct Battlesnake {
|
||||
}
|
||||
|
||||
impl Battlesnake {
|
||||
pub fn from_game_snake(snake: &crate::Battlesnake) -> Self {
|
||||
#[must_use] pub fn from_game_snake(snake: &crate::Battlesnake) -> Self {
|
||||
let body: VecDeque<_> = snake.body.iter().copied().collect();
|
||||
debug_assert_eq!(body.len(), usize::try_from(snake.length).unwrap());
|
||||
debug_assert!(snake.health <= crate::MAX_HEALTH);
|
||||
@ -295,7 +295,7 @@ impl Battlesnake {
|
||||
self.health = self.health.saturating_sub(1);
|
||||
}
|
||||
|
||||
pub fn head(&self) -> &Coord {
|
||||
#[must_use] pub fn head(&self) -> &Coord {
|
||||
debug_assert!(!self.body.is_empty());
|
||||
self.body.front().expect("not empty")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user