diff --git a/scripts/test.sh b/scripts/test.sh index 03707d1..e6f21bd 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -7,6 +7,6 @@ fi cargo fmt -- --check cargo clippy --all-targets --all-features -- -D warnings -cargo check +cargo check --frozen cargo test cargo test -- --ignored diff --git a/src/index/io.rs b/src/index/io.rs index dde0944..044539b 100644 --- a/src/index/io.rs +++ b/src/index/io.rs @@ -55,7 +55,7 @@ impl Index { fs::create_dir_all( path.as_ref() .parent() - .ok_or(anyhow!("cannot compute parent path for {}", path.as_ref().to_string_lossy()))?, + .ok_or_else(|| anyhow!("cannot compute parent path for {}", path.as_ref().to_string_lossy()))?, ) .context("create index directory")?; @@ -108,10 +108,7 @@ impl Index { Ok(self .index_file_path() .parent() - .ok_or(anyhow!( - "cannot compute parent path for {}", - self.index_file_path().to_string_lossy() - ))? + .ok_or_else(|| anyhow!("cannot compute parent path for {}", self.index_file_path().to_string_lossy()))? .to_path_buf()) } } diff --git a/src/repository.rs b/src/repository.rs index 0b7bfe7..d7ae664 100644 --- a/src/repository.rs +++ b/src/repository.rs @@ -113,10 +113,9 @@ impl<'a> Repository<'a> { let destination_path = Path::new(&destination_path); if source_path.is_file() { - let parent = destination_path.parent().ok_or(anyhow!( - "cannot compute parent path for {}", - &destination_path.to_string_lossy() - ))?; + let parent = destination_path + .parent() + .ok_or_else(|| anyhow!("cannot compute parent path for {}", &destination_path.to_string_lossy()))?; fs::create_dir_all(parent)?; fs::copy(source_path, destination_path)?; let relative_path = destination_path.strip_prefix(self.path)?; diff --git a/src/repository_item.rs b/src/repository_item.rs index 86df6d7..2370c39 100644 --- a/src/repository_item.rs +++ b/src/repository_item.rs @@ -36,7 +36,7 @@ impl RepositoryItem { } let parent = target_path .parent() - .ok_or(anyhow!("cannot compute parent path for {}", &target_path.to_string_lossy()))?; + .ok_or_else(|| anyhow!("cannot compute parent path for {}", &target_path.to_string_lossy()))?; if !parent.exists() { fs::create_dir_all(parent)?; }