Skip to content

Commit

Permalink
style: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
justinrubek committed Mar 18, 2023
1 parent 2f8004f commit d2c10b1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
14 changes: 9 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ impl App {
if let Some(by_file) = by_file {
for (path, config) in by_file {
let mut replacers = match &config.search_value {
Some(value) => {
SearchReplacer::new(path.clone(), &args.old_version, value, &args.new_version)?
Some(value) => SearchReplacer::new(
path.clone(),
&args.old_version,
value,
&args.new_version,
)?
.determine_replacements()?,
None => {
SimpleReplacer::new(path.clone(), &args.old_version, &args.new_version)?
.determine_replacements()?
}
None => SimpleReplacer::new(path.clone(), &args.old_version, &args.new_version)?
.determine_replacements()?,
};

// append new replacers to the list
Expand Down Expand Up @@ -76,7 +81,6 @@ impl App {
}
}


Ok(())
}
}
1 change: 0 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub enum Error {
InvalidReplacementCount(usize),
#[error("invalid cargo.toml: {0}")]
InvalidCargoToml(cargo_metadata::camino::Utf8PathBuf),

}

impl std::fmt::Debug for Error {
Expand Down
9 changes: 3 additions & 6 deletions src/replacers/cargo.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{io::prelude::*, path::PathBuf, str::FromStr};

use super::VersionReplacement;
use super::file::FileReplacer;
use super::VersionReplacement;
use crate::config::CargoReplaceMode;
use crate::error::{Error, Result};
use crate::replacers::Replacer;
Expand All @@ -16,10 +16,7 @@ pub struct CargoReplacer {
}

impl CargoReplacer {
pub fn new(
versions: VersionReplacement,
replace_mode: CargoReplaceMode,
) -> Result<Self> {
pub fn new(versions: VersionReplacement, replace_mode: CargoReplaceMode) -> Result<Self> {
Ok(Self {
// TODO: This may need to be specified, or detected
path: PathBuf::from("Cargo.lock"),
Expand Down Expand Up @@ -50,7 +47,7 @@ impl Replacer for CargoReplacer {
.iter()
.map(|package| package.name.as_str().to_string())
.collect::<Vec<String>>();

// update cargo.lock with new versions of packages
lockfile.packages.iter_mut().for_each(|package| {
let package_name = package.name.as_str().to_string();
Expand Down
14 changes: 4 additions & 10 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::{io::Read, path::Path};
use file::FileJail;

use crate::{
config::{Config, FileTableData, CargoReplaceMode},
replacers::{search::SearchReplacer, Replacer, cargo::CargoReplacer, VersionReplacement},
config::{CargoReplaceMode, Config, FileTableData},
replacers::{cargo::CargoReplacer, search::SearchReplacer, Replacer, VersionReplacement},
};

#[test]
Expand Down Expand Up @@ -191,7 +191,6 @@ name = "package1"
required-features = []
"#;


jail.create_file(
"src/main.rs",
r#"fn main() {
Expand Down Expand Up @@ -221,7 +220,6 @@ version = "0.1.0"
name = "package3"
version = "0.1.0"
"#,

)?;

let expected_lock = r#"# This file is automatically @generated by Cargo.
Expand Down Expand Up @@ -250,10 +248,8 @@ version = "0.1.0"
new_version: "0.2.0".to_string(),
};

let replacers = CargoReplacer::new(
version_replacement,
CargoReplaceMode::Autodetect,
)?.determine_replacements()?;
let replacers = CargoReplacer::new(version_replacement, CargoReplaceMode::Autodetect)?
.determine_replacements()?;

for replacer in replacers {
for replacer in replacer {
Expand All @@ -273,5 +269,3 @@ version = "0.1.0"
Ok(())
});
}


0 comments on commit d2c10b1

Please sign in to comment.