chiark / gitweb /
debug wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 6 Sep 2020 11:09:56 +0000 (12:09 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 6 Sep 2020 11:09:56 +0000 (12:09 +0100)
src/gamestate.rs
src/updates.rs

index c93fa041fc79ffa0ba78b67c7308655fe3391b01..25ee947959f4c6fac2606d51507e5b393caf0755 100644 (file)
@@ -22,7 +22,7 @@ visible_slotmap_key!{ VisiblePieceId('.') }
 #[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);
 
@@ -178,6 +178,17 @@ impl Html {
   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 {
index 8fbadf27637c5ee85d3125ad2093148c106bb893..323783fb2730998b740e5b33ead88b17daac98f5 100644 (file)
@@ -126,7 +126,7 @@ impl PreparedUpdateEntry {
     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