From 3d15c1a92fc2f0734cb893a328a3d01b17cfd202 Mon Sep 17 00:00:00 2001 From: armandocumate Date: Fri, 14 Oct 2022 16:18:39 -0700 Subject: [PATCH] fix diff inside code block --- src/game-of-life/debugging.md | 49 ++++++++++++++--------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/src/game-of-life/debugging.md b/src/game-of-life/debugging.md index f32e6fdf..e68b288a 100644 --- a/src/game-of-life/debugging.md +++ b/src/game-of-life/debugging.md @@ -68,35 +68,26 @@ Now, we can start logging messages to the console by inserting calls to `log` in Rust code. For example, to log each cell's state, live neighbors count, and next state, we could modify `wasm-game-of-life/src/lib.rs` like this: -```diff -diff --git a/src/lib.rs b/src/lib.rs -index f757641..a30e107 100755 ---- a/src/lib.rs -+++ b/src/lib.rs -@@ -123,6 +122,14 @@ impl Universe { - let cell = self.cells[idx]; - let live_neighbors = self.live_neighbor_count(row, col); - -+ log!( -+ "cell[{}, {}] is initially {:?} and has {} live neighbors", -+ row, -+ col, -+ cell, -+ live_neighbors -+ ); -+ - let next_cell = match (cell, live_neighbors) { - // Rule 1: Any live cell with fewer than two live neighbours - // dies, as if caused by underpopulation. -@@ -140,6 +147,8 @@ impl Universe { - (otherwise, _) => otherwise, - }; - -+ log!(" it becomes {:?}", next_cell); -+ - next[idx] = next_cell; - } - } +```rust +#[wasm_bindgen] +impl Universe { + // ... + + let cell = self.cells[idx]; + let live_neighbors = self.live_neighbor_count(row, col); + + log!( + "cell[{}, {}] is initially {:?} and has {} live neighbors", + row, + col, + cell, + live_neighbors + ); + + // ... + log!(" it becomes {:?}", next_cell); + next[idx] = next_cell; + } ``` ## Using a Debugger to Pause Between Each Tick