remove instruction related code
This commit is contained in:
		
							parent
							
								
									c1685f7f6e
								
							
						
					
					
						commit
						00405e0df5
					
				
							
								
								
									
										28
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								src/main.rs
									
									
									
									
									
								
							@ -135,13 +135,6 @@ enum Orientation {
 | 
				
			|||||||
    W,
 | 
					    W,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Enum to store all possible instructions.
 | 
					 | 
				
			||||||
enum Instruction {
 | 
					 | 
				
			||||||
    L,
 | 
					 | 
				
			||||||
    R,
 | 
					 | 
				
			||||||
    F,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/// Parse char and return corresponding orientation.
 | 
					/// Parse char and return corresponding orientation.
 | 
				
			||||||
fn parse_orientation(c: char) -> Result<Orientation, &'static str> {
 | 
					fn parse_orientation(c: char) -> Result<Orientation, &'static str> {
 | 
				
			||||||
    match c {
 | 
					    match c {
 | 
				
			||||||
@ -153,15 +146,6 @@ fn parse_orientation(c: char) -> Result<Orientation, &'static str> {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Parse char and return corresponding instruction.
 | 
					 | 
				
			||||||
fn parse_instruction(c: char) -> Result<Instruction, &'static str> {
 | 
					 | 
				
			||||||
    match c {
 | 
					 | 
				
			||||||
        'L' => Ok(Instruction::L),
 | 
					 | 
				
			||||||
        'R' => Ok(Instruction::R),
 | 
					 | 
				
			||||||
        'F' => Ok(Instruction::F),
 | 
					 | 
				
			||||||
        _ => Err("Invalid character, does not match any instructions"),
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Retrieve the content of a file and return it as a string.
 | 
					/// Retrieve the content of a file and return it as a string.
 | 
				
			||||||
fn open_file(filename: &str) -> io::Result<String> {
 | 
					fn open_file(filename: &str) -> io::Result<String> {
 | 
				
			||||||
@ -204,14 +188,6 @@ mod tests {
 | 
				
			|||||||
        assert!(parse_orientation('Z').is_err());
 | 
					        assert!(parse_orientation('Z').is_err());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[test]
 | 
					 | 
				
			||||||
    fn test_parse_instruction() {
 | 
					 | 
				
			||||||
        assert!(parse_instruction('L').is_ok());
 | 
					 | 
				
			||||||
        assert!(parse_instruction('R').is_ok());
 | 
					 | 
				
			||||||
        assert!(parse_instruction('F').is_ok());
 | 
					 | 
				
			||||||
        assert!(parse_instruction('Z').is_err());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    #[test]
 | 
					    #[test]
 | 
				
			||||||
    fn test_open_file() {
 | 
					    fn test_open_file() {
 | 
				
			||||||
        assert!(open_file("two_robots.txt").is_ok());
 | 
					        assert!(open_file("two_robots.txt").is_ok());
 | 
				
			||||||
@ -289,10 +265,6 @@ mod tests {
 | 
				
			|||||||
        w.create();
 | 
					        w.create();
 | 
				
			||||||
        r.move_forward(&mut w);
 | 
					        r.move_forward(&mut w);
 | 
				
			||||||
        assert_eq!(0, r.p.y);
 | 
					        assert_eq!(0, r.p.y);
 | 
				
			||||||
        r.move_right(&mut w);
 | 
					 | 
				
			||||||
        assert_eq!(2, r.p.x);
 | 
					 | 
				
			||||||
        r.move_left(&mut w);
 | 
					 | 
				
			||||||
        assert_eq!(1, r.p.x);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[test]
 | 
					    #[test]
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user