Skip to content

Commit 528cf7d

Browse files
committed
add a virtual workspace so subprojects are detected if the main repository is opened in an IDE
1 parent a1ff248 commit 528cf7d

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[workspace]
2+
members = [ "example/*", "exercise/*" ]

example/puzzle_game/src/main.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ fn get_puzzle(filename: &str) -> Result<Puzzle> {
1212

1313
fn main() -> Result<()> {
1414
env_logger::init();
15-
let puzzle = match get_puzzle("puzzle.dat").context("Couldn't get the first puzzle") {
15+
// This gets the absolute path to the puzzle.dat file in examples/puzzle_game no matter what
16+
// directory you are in when you run the `cargo run` command.
17+
let puzzle_file_path = &format!("{}/{}", env!("CARGO_MANIFEST_DIR"), "puzzle.dat");
18+
let puzzle = match get_puzzle(puzzle_file_path).context("Couldn't get the first puzzle") {
1619
Ok(p) => p,
1720
Err(_) => Puzzle::new(),
1821
};

example/puzzles/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ impl Puzzle {
2929
}
3030
/// Load a puzzle from a file
3131
pub fn from_file(_fh: File) -> Result<Self, PuzzleError> {
32+
println!("HERE");
3233
error!("This file is missing a piece!");
3334
Err(PuzzleError::MissingPiece)
3435
}

0 commit comments

Comments
 (0)