Unnamed repository; edit this file 'description' to name the repository.
minor: Accept `impl AsRef<Path>` in loader's runtime_file helper
This is purely for ergonomics: we should be able to pass strings for
example
crate::runtime_file(format!("namespace/{foo}/{bar}.txt"))
(Note that this works on Windows, see the `Path` documentation.)
| -rw-r--r-- | helix-loader/src/grammar.rs | 2 | ||||
| -rw-r--r-- | helix-loader/src/lib.rs | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/helix-loader/src/grammar.rs b/helix-loader/src/grammar.rs index 7e4fc2b5..29bcf07f 100644 --- a/helix-loader/src/grammar.rs +++ b/helix-loader/src/grammar.rs @@ -592,6 +592,6 @@ fn mtime(path: &Path) -> Result<SystemTime> { /// Gives the contents of a file from a language's `runtime/queries/<lang>` /// directory pub fn load_runtime_file(language: &str, filename: &str) -> Result<String, std::io::Error> { - let path = crate::runtime_file(&PathBuf::new().join("queries").join(language).join(filename)); + let path = crate::runtime_file(PathBuf::new().join("queries").join(language).join(filename)); std::fs::read_to_string(path) } diff --git a/helix-loader/src/lib.rs b/helix-loader/src/lib.rs index 0e7c134d..ae9ffe55 100644 --- a/helix-loader/src/lib.rs +++ b/helix-loader/src/lib.rs @@ -107,8 +107,8 @@ fn find_runtime_file(rel_path: &Path) -> Option<PathBuf> { /// The valid runtime directories are searched in priority order and the first /// file found to exist is returned, otherwise the path to the final attempt /// that failed. -pub fn runtime_file(rel_path: &Path) -> PathBuf { - find_runtime_file(rel_path).unwrap_or_else(|| { +pub fn runtime_file(rel_path: impl AsRef<Path>) -> PathBuf { + find_runtime_file(rel_path.as_ref()).unwrap_or_else(|| { RUNTIME_DIRS .last() .map(|dir| dir.join(rel_path)) |