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
29 impl fmt::Show for square {
30 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
31 write!(f, "{}", match *self {
32 bot => { "R".to_string() }
33 wall => { "#".to_string() }
34 rock => { "*".to_string() }
35 lambda => { "\\".to_string() }
36 closed_lift => { "L".to_string() }
37 open_lift => { "O".to_string() }
38 earth => { ".".to_string() }
39 empty => { " ".to_string() }
44 fn square_from_char(c: char) -> square {
50 'L' => { closed_lift }
55 println!("invalid square: {}", c);
61 fn read_board_grid<rdr:'static + io::Reader>(mut input: rdr)
63 let mut input: &mut io::Reader = &mut input;
64 let mut grid = Vec::new();
65 let mut line = [0, ..10];
67 let mut row = Vec::new();
68 for c in line.iter() {
69 row.push(square_from_char(*c as char))
72 let width = grid[0].len();
73 for row in grid.iter() { assert!(row.len() == width) }
79 pub fn trivial_to_string() {
80 assert!(lambda.to_string() == "\\")