diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..3dafcbe --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,2 @@ +[workspace] +members = [ "example/*", "exercise/*" ] diff --git a/example/puzzle_game/src/main.rs b/example/puzzle_game/src/main.rs index 591d97c..f980b2e 100644 --- a/example/puzzle_game/src/main.rs +++ b/example/puzzle_game/src/main.rs @@ -12,7 +12,10 @@ fn get_puzzle(filename: &str) -> Result { fn main() -> Result<()> { env_logger::init(); - let puzzle = match get_puzzle("puzzle.dat").context("Couldn't get the first puzzle") { + // This gets the absolute path to the puzzle.dat file in examples/puzzle_game no matter what + // directory you are in when you run the `cargo run` command. + let puzzle_file_path = &format!("{}/{}", env!("CARGO_MANIFEST_DIR"), "puzzle.dat"); + let puzzle = match get_puzzle(puzzle_file_path).context("Couldn't get the first puzzle") { Ok(p) => p, Err(_) => Puzzle::new(), }; diff --git a/example/puzzles/src/lib.rs b/example/puzzles/src/lib.rs index 5ffddf0..f1bdd3e 100644 --- a/example/puzzles/src/lib.rs +++ b/example/puzzles/src/lib.rs @@ -29,6 +29,7 @@ impl Puzzle { } /// Load a puzzle from a file pub fn from_file(_fh: File) -> Result { + println!("HERE"); error!("This file is missing a piece!"); Err(PuzzleError::MissingPiece) }