Skip to content

Commit 2129aef

Browse files
committed
feat: add current_path() based on build type
1 parent 31d9bd4 commit 2129aef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,19 @@ fn main() -> Result<()> {
88

99
Ok(())
1010
}
11+
12+
#[allow(dead_code)]
13+
#[cfg(not(debug_assertions))]
14+
fn current_path() -> Result<std::path::PathBuf> {
15+
std::env::current_exe()
16+
.map_err(|e| e.to_string())
17+
.map_err(Error::Generic)
18+
}
19+
20+
#[allow(dead_code)]
21+
#[cfg(debug_assertions)]
22+
fn current_path() -> Result<std::path::PathBuf> {
23+
std::env::current_dir()
24+
.map_err(|e| e.to_string())
25+
.map_err(Error::Generic)
26+
}

0 commit comments

Comments
 (0)