From ed6683797f28366e8bbbc2846b3bb71df7127812 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 27 Jun 2020 13:51:24 +0100 Subject: [PATCH] impl slotmap::Key --- src/keydata.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/keydata.rs b/src/keydata.rs index 60e2e2a7..44b2ea51 100644 --- a/src/keydata.rs +++ b/src/keydata.rs @@ -37,7 +37,8 @@ pub fn slotkey_write(k : SKD, sep : char, f : &mut fmt::Formatter) { #[macro_export] macro_rules! visible_slotmap_key { ( $x:ident ) => { - #[derive(Copy,Clone,Serialize,Deserialize)] + + #[derive(Copy,Clone,Eq,PartialEq,Ord,PartialOrd,Serialize,Deserialize)] #[serde(into="String")] #[serde(try_from="&str")] pub struct $x(pub slotmap::KeyData); @@ -54,6 +55,16 @@ macro_rules! visible_slotmap_key { VisiblePieceId(slotkey_parse(s,'.')?) } } + + impl slotmap::Key for $x { } + impl From for $x { + fn from(d : slotmap::KeyData) -> Self { $x(d) } + } + impl From<$x> for slotmap::KeyData { + fn from(p : $x) -> Self { + p.0 + } + } } } pub use crate::visible_slotmap_key; // this is madness! -- 2.30.2