<commit_before>use engine::{Map, Tile};
use engine::builders::{MapBuilder, MapBuildError, MapBuildResult};

use std::iter::{IteratorExt};

pub struct MapFromString {
    s: String,
}

impl MapFromString {

    pub fn new(s: &str) -> MapFromString {
        MapFromString { s: s.to_string() }
    }

    fn build_line(&self, line: &str) -> Vec<Tile> {
        line.chars().map(|char| self.build_cell(char)).collect()
    }

    fn build_cell(&self, cell: char) -> Tile {
        match cell {
            ' ' => Tile::Empty,
            '.' => Tile::Floor,
            '#' => Tile::Wall,
            _ => { panic!("Invalid character in level string: {}", cell); }
        }
    }
}

impl MapBuilder for MapFromString {
    fn build(&self) -> MapBuildResult {
        let lines : Vec<_> = self.s.split('\n').collect();

        if !lines.iter().all(|x| x.len() == lines[0].len()) { return Err(MapBuildError::new("Different length lines")) };

        println!("{}", lines);

        let tiles: Vec<Vec<Tile>> = lines.iter().map(|&line| self.build_line(line)).collect();

        println!("{}", tiles);

        Ok(Map::new(tiles))
    }
}
<commit_msg>Remove debug statements in MapFromString<commit_after>use engine::{Map, Tile};
use engine::builders::{MapBuilder, MapBuildError, MapBuildResult};

use std::iter::{IteratorExt};

pub struct MapFromString {
    s: String,
}

impl MapFromString {

    pub fn new(s: &str) -> MapFromString {
        MapFromString { s: s.to_string() }
    }

    fn build_line(&self, line: &str) -> Vec<Tile> {
        line.chars().map(|char| self.build_cell(char)).collect()
    }

    fn build_cell(&self, cell: char) -> Tile {
        match cell {
            ' ' => Tile::Empty,
            '.' => Tile::Floor,
            '#' => Tile::Wall,
            _ => { panic!("Invalid character in level string: {}", cell); }
        }
    }
}

impl MapBuilder for MapFromString {
    fn build(&self) -> MapBuildResult {
        let lines : Vec<_> = self.s.split('\n').collect();

        if !lines.iter().all(|x| x.len() == lines[0].len()) { return Err(MapBuildError::new("Different length lines")) };

        let tiles: Vec<Vec<Tile>> = lines.iter().map(|&line| self.build_line(line)).collect();

        Ok(Map::new(tiles))
    }
}

{'fraction_non_alphanumeric': 0.18592297476759628, 'fraction_numerical': 0.0008853474988933156, 'mean_word_length': 2.6988543371522096, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2962054', 'n_tokens_mistral': 741, 'n_tokens_neox': 723, 'n_words': 152}