Skip to content

Commit a9f612d

Browse files
authored
Resolve CARGO_MANIFEST_DIR at runtime (#28)
1 parent 54dec91 commit a9f612d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "include-file"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
description = "Include sections of files into Rust source code"
55
readme = "README.md"
66
authors = ["Heath Stewart (https://github.com/heaths)"]

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod textile;
1212

1313
use proc_macro2::{Span, TokenStream};
1414
use std::{
15-
fmt, fs,
15+
env, fmt, fs,
1616
io::{self, BufRead},
1717
path::PathBuf,
1818
};
@@ -237,8 +237,8 @@ where
237237
}
238238

239239
fn open(path: &str) -> io::Result<fs::File> {
240-
let manifest_dir: PathBuf = option_env!("CARGO_MANIFEST_DIR")
241-
.ok_or_else(|| io::Error::other("no manifest directory"))?
240+
let manifest_dir: PathBuf = env::var("CARGO_MANIFEST_DIR")
241+
.map_err(|_| io::Error::other("no manifest directory"))?
242242
.into();
243243
let path = manifest_dir.join(path);
244244
fs::File::open(path)

0 commit comments

Comments
 (0)