From dcd0fd612aa115560e97177ac39243f05619f185 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Fri, 23 Jun 2023 15:54:03 -0400 Subject: [PATCH] Fix clippy issues (#979) * Clippy * Missing docs * Broken doc links --- emergence_lib/src/construction/terraform.rs | 6 ++++++ emergence_lib/src/construction/zoning.rs | 4 ++-- emergence_lib/src/geometry/indexing.rs | 2 +- emergence_lib/src/player_interaction/mod.rs | 4 +--- emergence_lib/src/player_interaction/picking.rs | 1 + emergence_lib/src/structures/mod.rs | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/emergence_lib/src/construction/terraform.rs b/emergence_lib/src/construction/terraform.rs index a3d4795a2..3a09fa9a7 100644 --- a/emergence_lib/src/construction/terraform.rs +++ b/emergence_lib/src/construction/terraform.rs @@ -216,9 +216,13 @@ impl TerraformingCommandsExt for Commands<'_, '_> { } } +/// A command to initialize a terraforming action. struct TerraformCommand { + /// The hex where the terraforming action is taking place. hex: Hex, + /// The terraforming action to perform. action: TerraformingAction, + /// Is this a preview of the terraforming action? preview: bool, } @@ -288,7 +292,9 @@ impl Command for TerraformCommand { } } +/// A command to cancel a terraforming action. struct CancelTerraformCommand { + /// The hex where the terraforming action is taking place. hex: Hex, } diff --git a/emergence_lib/src/construction/zoning.rs b/emergence_lib/src/construction/zoning.rs index c88c8f37c..a6644110d 100644 --- a/emergence_lib/src/construction/zoning.rs +++ b/emergence_lib/src/construction/zoning.rs @@ -84,12 +84,12 @@ fn set_zoning( Tool::Terraform(terraform_tool) => match apply_zoning { true => { for voxel_pos in relevant_tiles.iter() { - commands.start_terraform(voxel_pos.hex, terraform_tool.clone().into()); + commands.start_terraform(voxel_pos.hex, (*terraform_tool).into()); } } false => { for &voxel_pos in relevant_tiles.iter() { - commands.preview_terraform(voxel_pos.hex, terraform_tool.clone().into()); + commands.preview_terraform(voxel_pos.hex, (*terraform_tool).into()); } } }, diff --git a/emergence_lib/src/geometry/indexing.rs b/emergence_lib/src/geometry/indexing.rs index 034015cad..972c31ab6 100644 --- a/emergence_lib/src/geometry/indexing.rs +++ b/emergence_lib/src/geometry/indexing.rs @@ -914,7 +914,7 @@ impl MapGeometry { assert!( // The set of keys should be larger, because it accounts for all possible origins // Units and signals must be able to *leave* any voxel - walkable_voxels.difference(&walkable_neighbors_keys).into_iter().count() == 0, + walkable_voxels.difference(&walkable_neighbors_keys).count() == 0, "Walkable voxels and walkable neighbors keys have desynced. Found {:?} in walkable voxels but not in walkable neighbors keys.", walkable_voxels.difference(&walkable_neighbors_keys) ); diff --git a/emergence_lib/src/player_interaction/mod.rs b/emergence_lib/src/player_interaction/mod.rs index cf7703ce4..8824f94bf 100644 --- a/emergence_lib/src/player_interaction/mod.rs +++ b/emergence_lib/src/player_interaction/mod.rs @@ -97,10 +97,8 @@ pub(crate) enum PlayerAction { /// If there is no structure there, the player's selection is cleared. Copy, /// Sets the zoning of all currently selected tiles to the currently selected structure. - /// - /// If no structure is selected to build, zoning will be set to [`Zoning::None`](crate::construction::zoning::Zoning::None). Paste, - /// Sets the zoning of all currently selected tiles to [`Zoning::None`](crate::construction::zoning::Zoning::None). + /// Cancels any planned actions (ghosts) selected. ClearZoning, /// Rotates the contents of the clipboard counterclockwise. RotateClipboardLeft, diff --git a/emergence_lib/src/player_interaction/picking.rs b/emergence_lib/src/player_interaction/picking.rs index 85dcac212..adbabc051 100644 --- a/emergence_lib/src/player_interaction/picking.rs +++ b/emergence_lib/src/player_interaction/picking.rs @@ -90,6 +90,7 @@ fn update_raycast_with_cursor( } } +/// A marker that's used to identify meshes and sources for raycasting. #[derive(Debug, Clone, Copy, PartialEq, Eq, Reflect, FromReflect)] pub(crate) struct PickableVoxel; diff --git a/emergence_lib/src/structures/mod.rs b/emergence_lib/src/structures/mod.rs index 69038ffc5..6edbe6fb6 100644 --- a/emergence_lib/src/structures/mod.rs +++ b/emergence_lib/src/structures/mod.rs @@ -208,7 +208,7 @@ mod tests { /// beginning at the origin and moving right one. /// /// This is a horizontal line, in the axial coordinate diagram shown here: - /// https://www.redblobgames.com/grids/hexagons/#coordinates + /// fn two_tile_footprint() -> Footprint { let mut set = HashSet::new(); set.insert(VoxelPos::ZERO);