Skip to content

Commit 441b2c2

Browse files
committed
Fix clippy warnings
1 parent b192f9c commit 441b2c2

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/commands/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use xz2::read::XzDecoder;
1717

1818
use crate::{
1919
check_hash, create_tarball,
20-
package::{Info, Package, Source, StepVariant},
20+
package::{Package, Source, StepVariant},
2121
};
2222

2323
pub async fn build() -> Result<()> {
@@ -46,7 +46,7 @@ pub async fn build() -> Result<()> {
4646
}
4747

4848
for source in &package.sources {
49-
let file_path = fetch_and_verify_source(&client, source, &info).await?;
49+
let file_path = fetch_and_verify_source(&client, source).await?;
5050
extract_source(&file_path)?;
5151
}
5252

@@ -68,7 +68,7 @@ pub async fn build() -> Result<()> {
6868
}
6969
}
7070
StepVariant::Move { path } => {
71-
fs::create_dir_all(&path)?;
71+
fs::create_dir_all(path)?;
7272

7373
working_dir = path.into();
7474
}
@@ -81,7 +81,7 @@ pub async fn build() -> Result<()> {
8181
Ok(())
8282
}
8383

84-
async fn fetch_and_verify_source(client: &Client, source: &Source, info: &Info) -> Result<PathBuf> {
84+
async fn fetch_and_verify_source(client: &Client, source: &Source) -> Result<PathBuf> {
8585
let url: Url = source.url.as_str().try_into()?;
8686

8787
let target_path = PathBuf::from(url.path_segments().unwrap().last().unwrap());

src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
use std::{
2-
borrow::Cow,
32
env::current_dir,
43
fs::{self, File},
54
path::Path,
6-
sync::LazyLock,
75
};
86

97
use anyhow::{anyhow, bail, Result};
108
use flate2::{write::GzEncoder, Compression};
11-
use regex::Regex;
129
use sha2::{Digest, Sha256 as Sha256Hasher};
1310
use tracing::info;
1411

1512
pub mod commands;
1613
pub mod package;
1714

18-
use package::{Info, Package};
19-
20-
static VARIABLE_REGEX: LazyLock<Regex> =
21-
LazyLock::new(|| Regex::new(r"%\{([a-zA-Z0-9_]*)\}").expect("invalid regex"));
15+
use package::Package;
2216

2317
pub fn check_hash<P: AsRef<Path>>(path: P, hash: &str) -> Result<bool> {
2418
let file = fs::read(path)?;

src/package.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl Package {
128128
for step in package.steps.iter_mut() {
129129
match &mut step.variant {
130130
StepVariant::Command { command, .. } => {
131-
*command = replace_vars(command.as_str(), &variables).into();
131+
*command = replace_vars(command.as_str(), &variables);
132132
}
133133
StepVariant::Move { path } => {
134134
*path = replace_vars(path.as_str(), &variables).into();
@@ -140,7 +140,7 @@ impl Package {
140140
}
141141
}
142142

143-
fn replace_vars<'h>(haystack: &'h str, variables: &HashMap<&str, &str>) -> String {
143+
fn replace_vars(haystack: &str, variables: &HashMap<&str, &str>) -> String {
144144
VARIABLE_REGEX
145145
.replace_all(haystack, |caps: &Captures| {
146146
variables.get(&caps[1]).expect("Unknown variable") // FIXME: error handling

0 commit comments

Comments
 (0)