diff --git a/src/lib.rs b/src/lib.rs index 39144dd..bee63c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ mod error; mod searcher; mod types; -mod utils; pub use crate::error::Error; pub use crate::searcher::AddSearcher; diff --git a/src/searcher.rs b/src/searcher.rs index ead18e5..fcdc31f 100644 --- a/src/searcher.rs +++ b/src/searcher.rs @@ -6,7 +6,6 @@ use std::io::Read; use std::path::{Path, PathBuf}; use crate::types::Result; -use crate::utils; /// Stores Lua modules indexed by module name, and provides an `rlua::MetaMethod` /// to enable `require`ing the stored modules by name in an `rlua::Context`. @@ -113,17 +112,8 @@ where methods.add_meta_method(MetaMethod::Call, |lua_ctx, this, name: String| { match this.modules.get(&name) { Some(ref path) => { - let path = path.as_ref(); - - // Ensure `path` is relative to `$CARGO_MANIFEST_DIR`. - let path = if path.is_relative() { - utils::runtime_root().join(path) - } else { - path.to_path_buf() - }; - + let path = path.as_ref().to_path_buf(); let content = (this.transform)(path)?; - Ok(Value::Function( lua_ctx .load(&content) diff --git a/src/utils.rs b/src/utils.rs deleted file mode 100644 index 4969f97..0000000 --- a/src/utils.rs +++ /dev/null @@ -1,6 +0,0 @@ -use std::path::PathBuf; - -/// Return the value of `$CARGO_MANIFEST_DIR` at runtime. -pub(crate) fn runtime_root() -> PathBuf { - PathBuf::new().join(std::env::var("CARGO_MANIFEST_DIR").unwrap()) -}