pub struct PieceId;
}
-visible_slotmap_key!{VisiblePieceId}
-display_consequential_impls!{VisiblePieceId}
+visible_slotmap_key!{ VisiblePieceId('.') }
pub fn make_pieceid_visible(p : PieceId) -> VisiblePieceId {
// xxx need to do censorship mapping here
pub struct ClientId;
}
-visible_slotmap_key!{PlayerId}
-display_consequential_impls!{PlayerId}
+visible_slotmap_key!{ PlayerId('#') }
#[derive(Clone,Debug,Eq,PartialEq,Ord,PartialOrd,Hash)]
struct RawToken (String);
#[macro_export]
macro_rules! visible_slotmap_key {
- ( $x:ident ) => {
+ ( $x:ident($sep:expr) ) => {
#[derive(Copy,Clone,Eq,PartialEq,Ord,PartialOrd,Serialize,Deserialize)]
#[serde(into="String")]
impl Display for $x {
#[throws(fmt::Error)]
- fn fmt(&self, f : &mut fmt::Formatter) { slotkey_write(self.0,'.',f)? }
+ fn fmt(&self, f : &mut fmt::Formatter) { slotkey_write(self.0,$sep,f)? }
}
impl TryFrom<&str> for $x {
type Error = AE;
#[throws(AE)]
- fn try_from(s : &str) -> $x { $x(slotkey_parse(s,'.')?) }
+ fn try_from(s : &str) -> $x { $x(slotkey_parse(s,$sep)?) }
}
impl slotmap::Key for $x { }
p.0
}
}
+
+ display_consequential_impls!{$x}
}
}
pub use crate::visible_slotmap_key; // this is madness!