Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ripytide committed Dec 23, 2024
1 parent 0ba5985 commit 1559e37
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 73 deletions.
5 changes: 1 addition & 4 deletions src/backends/apt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ impl Backend for Apt {
run_command_for_stdout(["apt", "--version"], Perms::Same, false)
}

fn missing(
required: Self::Options,
installed: Option<Self::Options>,
) -> Option<Self::Options> {
fn missing(required: Self::Options, installed: Option<Self::Options>) -> Option<Self::Options> {
match installed {
Some(_) => None,
None => Some(required),
Expand Down
6 changes: 1 addition & 5 deletions src/backends/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ impl Backend for Arch {
Ok(())
}

fn remove(
packages: &BTreeSet<String>,
no_confirm: bool,
config: &Config,
) -> Result<()> {
fn remove(packages: &BTreeSet<String>, no_confirm: bool, config: &Config) -> Result<()> {
if !packages.is_empty() {
run_command(
[
Expand Down
11 changes: 2 additions & 9 deletions src/backends/brew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ impl Backend for Brew {
.collect())
}

fn install(
packages: &BTreeMap<String, Self::Options>,
_: bool,
_: &Config,
) -> Result<()> {
fn install(packages: &BTreeMap<String, Self::Options>, _: bool, _: &Config) -> Result<()> {
if !packages.is_empty() {
run_command(
["brew", "install"]
Expand Down Expand Up @@ -79,10 +75,7 @@ impl Backend for Brew {
run_command_for_stdout(["brew", "--version"], Perms::Same, false)
}

fn missing(
required: Self::Options,
installed: Option<Self::Options>,
) -> Option<Self::Options> {
fn missing(required: Self::Options, installed: Option<Self::Options>) -> Option<Self::Options> {
match installed {
Some(_) => None,
None => Some(required),
Expand Down
6 changes: 1 addition & 5 deletions src/backends/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ impl Backend for Cargo {
extract_packages(&contents).wrap_err("extracting packages from crates file")
}

fn install(
packages: &BTreeMap<String, Self::Options>,
_: bool,
_: &Config,
) -> Result<()> {
fn install(packages: &BTreeMap<String, Self::Options>, _: bool, _: &Config) -> Result<()> {
for (package, options) in packages {
run_command(
["cargo", "install"]
Expand Down
6 changes: 1 addition & 5 deletions src/backends/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ pub trait Backend {
config: &Config,
) -> Result<()>;

fn remove(
packages: &BTreeSet<String>,
no_confirm: bool,
config: &Config,
) -> Result<()>;
fn remove(packages: &BTreeSet<String>, no_confirm: bool, config: &Config) -> Result<()>;

fn clean_cache(config: &Config) -> Result<()>;

Expand Down
16 changes: 3 additions & 13 deletions src/backends/pipx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,10 @@ impl Backend for Pipx {
true,
)?)?;

Ok(names
.into_iter()
.map(|x| (x, Self::Options {}))
.collect())
Ok(names.into_iter().map(|x| (x, Self::Options {})).collect())
}

fn install(
packages: &BTreeMap<String, Self::Options>,
_: bool,
_: &Config,
) -> Result<()> {
fn install(packages: &BTreeMap<String, Self::Options>, _: bool, _: &Config) -> Result<()> {
if !packages.is_empty() {
run_command(
["pipx", "install"]
Expand Down Expand Up @@ -82,10 +75,7 @@ impl Backend for Pipx {
run_command_for_stdout(["pipx", "--version"], Perms::Same, false)
}

fn missing(
required: Self::Options,
installed: Option<Self::Options>,
) -> Option<Self::Options> {
fn missing(required: Self::Options, installed: Option<Self::Options>) -> Option<Self::Options> {
match installed {
Some(_) => None,
None => Some(required),
Expand Down
6 changes: 1 addition & 5 deletions src/backends/rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ impl Backend for Rustup {
Ok(packages)
}

fn install(
packages: &BTreeMap<String, Self::Options>,
_: bool,
_: &Config,
) -> Result<()> {
fn install(packages: &BTreeMap<String, Self::Options>, _: bool, _: &Config) -> Result<()> {
for (toolchain, rustup_options) in packages.iter() {
run_command(
["rustup", "toolchain", "install", toolchain.as_str()],
Expand Down
6 changes: 1 addition & 5 deletions src/backends/snap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ impl Backend for Snap {
.collect())
}

fn install(
packages: &BTreeMap<String, Self::Options>,
_: bool,
_: &Config,
) -> Result<()> {
fn install(packages: &BTreeMap<String, Self::Options>, _: bool, _: &Config) -> Result<()> {
if !packages.is_empty() {
run_command(
["snap", "install"]
Expand Down
11 changes: 2 additions & 9 deletions src/backends/winget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ impl Backend for WinGet {
.collect())
}

fn install(
packages: &BTreeMap<String, Self::Options>,
_: bool,
_: &Config,
) -> Result<()> {
fn install(packages: &BTreeMap<String, Self::Options>, _: bool, _: &Config) -> Result<()> {
if !packages.is_empty() {
run_command(
["winget", "install"]
Expand Down Expand Up @@ -101,10 +97,7 @@ impl Backend for WinGet {
run_command_for_stdout(["winget", "--version"], Perms::Same, false)
}

fn missing(
required: Self::Options,
installed: Option<Self::Options>,
) -> Option<Self::Options> {
fn missing(required: Self::Options, installed: Option<Self::Options>) -> Option<Self::Options> {
match installed {
Some(_) => None,
None => Some(required),
Expand Down
9 changes: 2 additions & 7 deletions src/backends/xbps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ impl Backend for Xbps {
Ok(packages)
}

fn query(
config: &Config,
) -> Result<std::collections::BTreeMap<String, Self::Options>> {
fn query(config: &Config) -> Result<std::collections::BTreeMap<String, Self::Options>> {
if Self::version(config).is_err() {
return Ok(BTreeMap::new());
}
Expand Down Expand Up @@ -95,10 +93,7 @@ impl Backend for Xbps {
run_command_for_stdout(["xbps-query", "--version"], Perms::Same, false)
}

fn missing(
required: Self::Options,
installed: Option<Self::Options>,
) -> Option<Self::Options> {
fn missing(required: Self::Options, installed: Option<Self::Options>) -> Option<Self::Options> {
match installed {
Some(_) => None,
None => Some(required),
Expand Down
3 changes: 1 addition & 2 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ impl CleanCacheCommand {
}

fn unmanaged(required: &Options, config: &Config) -> Result<PackageIds> {
Options::query(config)
.map(|x| x.to_package_ids().difference(&required.to_package_ids()))
Options::query(config).map(|x| x.to_package_ids().difference(&required.to_package_ids()))
}
fn missing(required: &Options, config: &Config) -> Result<Options> {
let installed = Options::query(config)?;
Expand Down
5 changes: 1 addition & 4 deletions src/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ impl Groups {
pub fn contains(&self, backend: AnyBackend, package: &str) -> Vec<PathBuf> {
let mut result = Vec::new();
for (group_file, raw_options) in self.0.iter() {
if raw_options
.to_raw_package_ids()
.contains(backend, package)
{
if raw_options.to_raw_package_ids().contains(backend, package) {
result.push(group_file.clone());
}
}
Expand Down

0 comments on commit 1559e37

Please sign in to comment.