2 #![allow(unused_must_use)]
5 #![allow(non_camel_case_types)]
10 use std::io::prelude::*;
11 use square::{bot, wall, rock, lambda, closed_lift, open_lift, earth, empty};
24 impl fmt::Debug for square {
25 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
26 write!(f, "{}", match *self {
27 bot => { "R".to_string() }
28 wall => { "#".to_string() }
29 rock => { "*".to_string() }
30 lambda => { "\\".to_string() }
31 closed_lift => { "L".to_string() }
32 open_lift => { "O".to_string() }
33 earth => { ".".to_string() }
34 empty => { " ".to_string() }
39 fn square_from_char(c: char) -> square {
45 'L' => { closed_lift }
50 println!("invalid square: {}", c);
56 fn read_board_grid<rdr:'static + Read>(mut input: rdr)
58 let mut input: &mut dyn Read = &mut input;
59 let mut grid = Vec::new();
60 let mut line = [0; 10];
61 input.read(&mut line);
62 let mut row = Vec::new();
64 row.push(square_from_char(*c as char))
67 let width = grid[0].len();
68 for row in &grid { assert_eq!(row.len(), width) }
74 pub fn trivial_to_string() {
75 assert_eq!(lambda.to_string(), "\\")