use iter to init board
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
shimun 2019-11-10 21:38:10 +01:00
parent e703d914ed
commit 6af10ba53d
Signed by: shimun
GPG Key ID: E81D8382DC2F971B

View File

@ -2,6 +2,7 @@ use std::env::args;
use std::fmt; use std::fmt;
use std::io; use std::io;
use std::io::Write; use std::io::Write;
use std::iter;
use std::ops::{Index, IndexMut}; use std::ops::{Index, IndexMut};
use std::str::FromStr; use std::str::FromStr;
@ -92,11 +93,7 @@ impl FromStr for Board {
impl Board { impl Board {
fn new(size: usize) -> Board { fn new(size: usize) -> Board {
let mut b = Vec::with_capacity(size * size); Board(iter::repeat(State::N).take(size * size).collect())
for _ in 0..b.capacity() {
b.push(State::N);
}
Board(b)
} }
fn dimension(&self) -> usize { fn dimension(&self) -> usize {