From f550c3696f23947f0666fa8bf3234c90e402acdc Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sat, 18 Apr 2020 18:07:25 +0100 Subject: [PATCH] handle errors for game --- src/bin/smiley.rs | 4 +++- src/game.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/smiley.rs b/src/bin/smiley.rs index 6b4d288..1bca3bc 100644 --- a/src/bin/smiley.rs +++ b/src/bin/smiley.rs @@ -12,7 +12,9 @@ fn main() { .nth(2) .expect("No output path specified. Usage: `smiley infile outfile`"); - let mut game = Game::from(fs::read_to_string(input_file).unwrap()); + let mut game = Game::from( + fs::read_to_string(input_file).unwrap() + ).unwrap(); game.avatar.animation_frames = vec![Image { pixels: vec![ diff --git a/src/game.rs b/src/game.rs index b0cf1a6..b052c11 100644 --- a/src/game.rs +++ b/src/game.rs @@ -41,7 +41,7 @@ pub struct Game { } impl Game { - fn from(string: String) -> Result { + pub fn from(string: String) -> Result { let mut string = format!("{}\n\n", string.trim_matches('\n')); if string.starts_with("# BITSY VERSION") {