Skip to content

Commit

Permalink
Formatting (using rustfmt)
Browse files Browse the repository at this point in the history
  • Loading branch information
svenfoo committed Sep 11, 2019
1 parent 15cd91f commit 8534ec3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
18 changes: 5 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,9 @@ impl Universe {
fn live_neighbor_count(&self, row: u32, column: u32) -> u8 {
let mut count = 0;

let north = if row == 0 {
self.height - 1
} else {
row - 1
};
let north = if row == 0 { self.height - 1 } else { row - 1 };

let south = if row == self.height - 1 {
0
} else {
row + 1
};
let south = if row == self.height - 1 { 0 } else { row + 1 };

let west = if column == 0 {
self.width - 1
Expand Down Expand Up @@ -124,13 +116,13 @@ impl Universe {
/// Public methods, exported to JavaScript.
#[wasm_bindgen]
impl Universe {
pub fn new(width : u32, height : u32) -> Universe {
pub fn new(width: u32, height: u32) -> Universe {
utils::set_panic_hook();

assert!(width > 0);
assert!(height > 0);

let cells = vec!(Cell::Dead; width as usize * height as usize);
let cells = vec![Cell::Dead; width as usize * height as usize];

Universe {
width,
Expand Down Expand Up @@ -200,7 +192,7 @@ impl Universe {
} else {
*c = Cell::Dead
}
};
}
}

pub fn clear(&mut self) {
Expand Down
3 changes: 1 addition & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ pub fn set_panic_hook() {
//
// For more details see
// https://github.com/rustwasm/console_error_panic_hook#readme
#[cfg(feature = "console_error_panic_hook")]
console_error_panic_hook::set_once();
#[cfg(feature = "console_error_panic_hook")] console_error_panic_hook::set_once();
}
4 changes: 2 additions & 2 deletions tests/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use wasm_game_of_life::Universe;
#[cfg(test)]
pub fn input_spaceship() -> Universe {
let mut universe = Universe::new(6, 6);
universe.set_cells_alive(&[(1,2), (2,3), (3,1), (3,2), (3,3)]);
universe.set_cells_alive(&[(1, 2), (2, 3), (3, 1), (3, 2), (3, 3)]);
universe
}

#[cfg(test)]
pub fn expected_spaceship() -> Universe {
let mut universe = Universe::new(6, 6);
universe.set_cells_alive(&[(2,1), (2,3), (3,2), (3,3), (4,2)]);
universe.set_cells_alive(&[(2, 1), (2, 3), (3, 2), (3, 3), (4, 2)]);
universe
}

Expand Down

0 comments on commit 8534ec3

Please sign in to comment.