From: Ian Jackson Date: Sat, 27 Jun 2020 12:51:24 +0000 (+0100) Subject: impl slotmap::Key X-Git-Tag: otter-0.2.0~1528 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ed6683797f28366e8bbbc2846b3bb71df7127812;p=otter.git impl slotmap::Key --- 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!