chore(examples): Remove relative path from reading data (#1220)

This commit is contained in:
tottoto
2023-01-09 12:47:40 -05:00
committed by GitHub
parent 0ca0630993
commit 1bef5f5757
8 changed files with 25 additions and 15 deletions
+2 -1
View File
@@ -15,7 +15,8 @@ struct Location {
#[allow(dead_code)]
pub fn load() -> Vec<crate::routeguide::Feature> {
let file = File::open("examples/data/route_guide_db.json").expect("failed to open data file");
let data_dir = std::path::PathBuf::from_iter([std::env!("CARGO_MANIFEST_DIR"), "data"]);
let file = File::open(data_dir.join("route_guide_db.json")).expect("failed to open data file");
let decoded: Vec<Feature> =
serde_json::from_reader(&file).expect("failed to deserialize features");