#[serde(try_from="f64")]
pub struct ZCoord(pub f64);
-#[derive(Clone,Debug,Serialize,Deserialize)]
+#[derive(Clone,Serialize,Deserialize)]
#[serde(transparent)]
pub struct Html (pub String);
pub fn lit(s: &str) -> Self { Html(s.to_owned()) }
}
+impl Debug for Html {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ const MAX : usize = 23;
+ if self.0.len() < MAX {
+ write!(f, "<{}>", &self.0)
+ } else {
+ write!(f, "<{}>...", &self.0[0..MAX-3])
+ }
+ }
+}
+
// ---------- game state - rendering etc. ----------
impl PieceState {
match self {
Piece { ref op, .. } => {
50 +
- op.new_state().map(|x| x.svg.0.len()).unwrap_or(0)
+ op.new_state().map(|x| x.svg.0.as_bytes().len()).unwrap_or(0)
},
Log(logent) => {
logent.html.0.as_bytes().len() * 3