group wires into one tool option

This commit is contained in:
Crispy 2024-10-05 19:45:25 +02:00
parent ea02eff82b
commit 465b5c40d1
4 changed files with 89 additions and 78 deletions

View file

@ -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 {