Add parse_orientation()
This function parse a char and return the matching direction or None
This commit is contained in:
		
							parent
							
								
									dcbc5aa74c
								
							
						
					
					
						commit
						c1143ee396
					
				
							
								
								
									
										10
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/main.rs
									
									
									
									
									
								
							| @ -11,6 +11,16 @@ enum Instruction { | |||||||
|     F, |     F, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | fn parse_orientation(c: char) -> Option<Orientation> { | ||||||
|  |     match c { | ||||||
|  |         'N' => Some(Orientation::N), | ||||||
|  |         'E' => Some(Orientation::E), | ||||||
|  |         'S' => Some(Orientation::S), | ||||||
|  |         'W' => Some(Orientation::W), | ||||||
|  |         _ => None, | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| fn main() { | fn main() { | ||||||
|     let file_data = include_str!("../two_robots.txt"); |     let file_data = include_str!("../two_robots.txt"); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 mhart
						mhart