chiark / gitweb /
debug RawToken better
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 5 Sep 2020 22:12:19 +0000 (23:12 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 5 Sep 2020 22:12:19 +0000 (23:12 +0100)
src/imports.rs
src/spec.rs

index d09dd4a6e192833f79ee6d42d95fda9350ecf05e..f38853f8d2bf8dfd6faac1dff1af666d729e4fb6 100644 (file)
@@ -17,7 +17,7 @@ pub use std::iter;
 pub use std::iter::repeat_with;
 pub use std::collections::VecDeque;
 pub use std::num::Wrapping;
-pub use std::cmp;
+pub use std::cmp::{self,min,max};
 pub use std::error::Error;
 pub use std::marker::PhantomData;
 pub use std::ops::{Deref,DerefMut};
index f13d6bcbb466800ce194cd3503b036d9c19c9e84..26943187007e8f46ea573b6847bde3358b9e7508 100644 (file)
@@ -15,7 +15,7 @@ pub type Coord = isize;
 
 pub type Pos = [Coord; 2];
 
-#[derive(Clone,Debug,Eq,PartialEq,Ord,PartialOrd,Hash,Serialize,Deserialize)]
+#[derive(Clone,Eq,PartialEq,Ord,PartialOrd,Hash,Serialize,Deserialize)]
 #[serde(transparent)]
 pub struct RawToken (pub String);
 
@@ -104,6 +104,14 @@ mod implementation {
   use crate::imports::*;
   type Insn = crate::commands::MgmtGameInstruction;
 
+  impl Debug for RawToken {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+      let s = &self.0;
+      let len = min(5, s.len() / 2);
+      write!(f, "{:?}...", &s[0..len])
+    }
+  }
+
   #[typetag::serde(tag="access")]
   pub trait PlayerAccessSpec : Debug {
     fn token_mgi(&self, _player: PlayerId) -> Option<MgmtGameInstruction> {