2 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
3 // file at the top-level directory of this distribution and at
4 // http://rust-lang.org/COPYRIGHT.
6 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9 // option. This file may not be copied, modified, or distributed
10 // except according to those terms.
13 /// Map representation
17 use square::{bot, wall, rock, lambda, closed_lift, open_lift, earth, empty};
30 impl fmt::Show for square {
31 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
32 write!(f, "{}", match *self {
33 bot => { "R".to_string() }
34 wall => { "#".to_string() }
35 rock => { "*".to_string() }
36 lambda => { "\\".to_string() }
37 closed_lift => { "L".to_string() }
38 open_lift => { "O".to_string() }
39 earth => { ".".to_string() }
40 empty => { " ".to_string() }
45 fn square_from_char(c: char) -> square {
51 'L' => { closed_lift }
56 println!("invalid square: {}", c);
62 fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr)
64 let mut input: &mut io::Reader = &mut input;
65 let mut grid = Vec::new();
66 let mut line = [0, ..10];
67 input.read(&mut line);
68 let mut row = Vec::new();
69 for c in line.iter() {
70 row.push(square_from_char(*c as char))
73 let width = grid[0].len();
74 for row in grid.iter() { assert!(row.len() == width) }
80 pub fn trivial_to_string() {
81 assert!(lambda.to_string() == "\\")