From f5be9c43236e86ae17cd2425afa0d3374a357fbc Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Mon, 30 Sep 2024 15:45:04 -0700 Subject: [PATCH 1/2] Use `unwrap_or` when creating relative path in loader --- src/loader.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/loader.rs b/src/loader.rs index 112ff78414..f33cf36d92 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -23,11 +23,7 @@ impl Loader { 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))) } From b5caacdb4f23833709acc230dd90eef52ddbd383 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Mon, 30 Sep 2024 15:46:04 -0700 Subject: [PATCH 2/2] Reform --- src/loader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loader.rs b/src/loader.rs index f33cf36d92..21e8f73216 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -19,7 +19,7 @@ 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, })?;