From 4193165476a05fb4b07849c5371af3c8b328d6cb Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Tue, 28 Apr 2020 11:46:51 +0200 Subject: derive Hash for Player/Gadget/Character/Agent It is very much possible and likely that someone would want to use a Player or Agent in a HashSet or HashMap, and there's no reason why that should be forbidden. --- src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index f438460..ee9146a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,7 +39,7 @@ pub enum EvtcError { } /// Player-specific agent data. -#[derive(Debug, Clone, PartialEq, Eq, CopyGetters)] +#[derive(Debug, Clone, Hash, PartialEq, Eq, CopyGetters)] pub struct Player { /// The player's profession. #[get_copy = "pub"] @@ -73,7 +73,7 @@ impl Player { } /// Gadget-specific agent data. -#[derive(Debug, Clone, PartialEq, Eq, CopyGetters)] +#[derive(Debug, Clone, Hash, PartialEq, Eq, CopyGetters)] pub struct Gadget { #[get_copy = "pub"] id: u16, @@ -86,7 +86,7 @@ impl Gadget { } } -#[derive(Debug, Clone, PartialEq, Eq, CopyGetters)] +#[derive(Debug, Clone, Hash, PartialEq, Eq, CopyGetters)] pub struct Character { #[get_copy = "pub"] id: u16, @@ -100,7 +100,7 @@ impl Character { } /// The type of an agent. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub enum AgentKind { Player(Player), Gadget(Gadget), @@ -189,7 +189,7 @@ impl AgentKind { /// `Kind`. An escape hatch is the method [`.erase()`][Agent::erase], which erases the kind /// information and produces the default `Agent<()>`. Functions/methods that only take `Agent<()>` /// can therefore be used by any other agent as well. -#[derive(Debug, Clone, Getters, CopyGetters)] +#[derive(Debug, Clone, Hash, PartialEq, Eq, Getters, CopyGetters)] // For the reasoning of #[repr(C)] see Agent::transmute. #[repr(C)] pub struct Agent { -- cgit v1.2.3