1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 #![allow(unused_must_use)]
15 #![allow(non_camel_case_types)]
20 use std::io::prelude::*;
21 use square::{bot, wall, rock, lambda, closed_lift, open_lift, earth, empty};
34 impl fmt::Debug for square {
35 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
36 write!(f, "{}", match *self {
37 bot => { "R".to_string() }
38 wall => { "#".to_string() }
39 rock => { "*".to_string() }
40 lambda => { "\\".to_string() }
41 closed_lift => { "L".to_string() }
42 open_lift => { "O".to_string() }
43 earth => { ".".to_string() }
44 empty => { " ".to_string() }
49 fn square_from_char(c: char) -> square {
55 'L' => { closed_lift }
60 println!("invalid square: {}", c);
66 fn read_board_grid<rdr:'static + Read>(mut input: rdr)
68 let mut input: &mut Read = &mut input;
69 let mut grid = Vec::new();
70 let mut line = [0; 10];
71 input.read(&mut line);
72 let mut row = Vec::new();
74 row.push(square_from_char(*c as char))
77 let width = grid[0].len();
78 for row in &grid { assert_eq!(row.len(), width) }
84 pub fn trivial_to_string() {
85 assert_eq!(lambda.to_string(), "\\")