use iter to init board
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e703d914ed
commit
6af10ba53d
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user