diff --git a/src/loader.rs b/src/loader.rs index 112ff78414..21e8f73216 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -19,15 +19,11 @@ impl Loader { path: &Path, ) -> RunResult<(&'src Path, &'src str)> { let src = fs::read_to_string(path).map_err(|io_error| Error::Load { - path: path.to_owned(), + path: path.into(), io_error, })?; - let relative = if let Ok(path) = path.strip_prefix(root.parent().unwrap()) { - path - } else { - path - }; + let relative = path.strip_prefix(root.parent().unwrap()).unwrap_or(path); Ok((self.paths.alloc(relative.into()), self.srcs.alloc(src))) }