diff options
author | Daniel Schadt <kingdread@gmx.de> | 2020-04-28 11:46:51 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2020-04-28 11:46:51 +0200 |
commit | 4193165476a05fb4b07849c5371af3c8b328d6cb (patch) | |
tree | dc538907bb53b4bbe5e1de4e9ac87d5a9ab386e8 /src/lib.rs | |
parent | 4c9adbcbbcea6d47c009d464c6f9d30a15b7fb1e (diff) | |
download | evtclib-4193165476a05fb4b07849c5371af3c8b328d6cb.tar.gz evtclib-4193165476a05fb4b07849c5371af3c8b328d6cb.tar.bz2 evtclib-4193165476a05fb4b07849c5371af3c8b328d6cb.zip |
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.
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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<Kind = ()> { |