group wires into one tool option
This commit is contained in:
parent
ea02eff82b
commit
465b5c40d1
4 changed files with 89 additions and 78 deletions
|
@ -35,6 +35,25 @@ pub struct Board {
|
|||
}
|
||||
|
||||
impl Board {
|
||||
pub fn parse(source: &str) -> Self {
|
||||
let mut rows = Vec::new();
|
||||
|
||||
let mut width = 0;
|
||||
for line in source.lines() {
|
||||
width = width.max(line.len());
|
||||
let mut tiles = Vec::new();
|
||||
for char in line.chars() {
|
||||
tiles.push(Tile::from_char(char));
|
||||
}
|
||||
rows.push(tiles);
|
||||
}
|
||||
for line in &mut rows {
|
||||
line.resize(width, Tile::Blank);
|
||||
}
|
||||
|
||||
Board::new(rows)
|
||||
}
|
||||
|
||||
pub fn new_empty(width: usize, height: usize) -> Self {
|
||||
let rows = vec![vec![Tile::Blank; width]; height];
|
||||
Self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue