fix more lints

This commit is contained in:
steven-omaha
2023-02-13 20:54:49 +01:00
parent 18a6f4db6a
commit 9d5e691924
12 changed files with 28 additions and 25 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ use crate::backend::backend_trait::*;
use crate::{impl_backend_constants, Group, Package};
#[derive(Debug)]
pub(crate) struct Pacman {
pub struct Pacman {
pub(crate) binary: String,
pub(crate) aur_rm_args: Option<Vec<String>>,
pub(crate) packages: HashSet<Package>,
+1 -1
View File
@@ -10,7 +10,7 @@ use crate::backend::backend_trait::*;
use crate::{impl_backend_constants, Group, Package};
#[derive(Debug)]
pub(crate) struct Rust {
pub struct Rust {
pub(crate) packages: HashSet<Package>,
}
+1 -1
View File
@@ -11,7 +11,7 @@ use crate::{Group, Package};
pub(in crate::backend) type Switches = &'static [&'static str];
pub(in crate::backend) type Text = &'static str;
pub(crate) trait Backend: Debug {
pub trait Backend: Debug {
fn get_binary(&self) -> Text;
fn get_section(&self) -> Text;
+1 -1
View File
@@ -1,7 +1,7 @@
use super::{Backend, Backends};
#[derive(Debug)]
pub(crate) struct BackendIter {
pub struct BackendIter {
pub(crate) next: Option<Backends>,
}
+3 -3
View File
@@ -4,9 +4,9 @@ mod iter;
mod macros;
mod todo_per_backend;
pub(crate) use backend_trait::Backend;
pub(crate) use iter::BackendIter;
pub(crate) use todo_per_backend::ToDoPerBackend;
pub use backend_trait::Backend;
pub use iter::BackendIter;
pub use todo_per_backend::ToDoPerBackend;
use ::macros::Register;
+1 -1
View File
@@ -6,7 +6,7 @@ use super::Backend;
use crate::Package;
#[derive(Debug)]
pub(crate) struct ToDoPerBackend(Vec<(Box<dyn Backend>, Vec<Package>)>);
pub struct ToDoPerBackend(Vec<(Box<dyn Backend>, Vec<Package>)>);
impl ToDoPerBackend {
pub(crate) fn new() -> Self {
+2 -1
View File
@@ -307,6 +307,7 @@ fn get_assumed_group_file_names(arg_match: &ArgMatches) -> Result<Vec<PathBuf>>
Ok(paths)
}
#[allow(clippy::option_if_let_else)]
fn show_error(error: &anyhow::Error, backend: &dyn Backend) {
let section = backend.get_section();
match get_single_var("RUST_BACKTRACE") {
@@ -319,7 +320,7 @@ fn show_error(error: &anyhow::Error, backend: &dyn Backend) {
}
}
pub(crate) const fn get_version_string() -> &'static str {
pub const fn get_version_string() -> &'static str {
concat!(
"pacdef, version: ",
env!("CARGO_PKG_VERSION"),
+2 -2
View File
@@ -2,7 +2,7 @@ use std::env::var;
use anyhow::{anyhow, Result};
pub(crate) fn get_editor() -> Result<String> {
pub fn get_editor() -> Result<String> {
check_vars_in_order(&["EDITOR", "VISUAL"]).ok_or_else(|| anyhow!("could not find editor"))
}
@@ -10,6 +10,6 @@ fn check_vars_in_order(vars: &[&str]) -> Option<String> {
vars.iter().find_map(|v| var(v).ok())
}
pub(crate) fn get_single_var(variable: &str) -> Option<String> {
pub fn get_single_var(variable: &str) -> Option<String> {
var(variable).ok()
}
+10 -8
View File
@@ -48,14 +48,16 @@ impl Package {
impl PartialEq for Package {
fn eq(&self, other: &Self) -> bool {
self.name == other.name
&& match &self.repo {
None => true,
Some(r) => match &other.repo {
None => true,
Some(r2) => r == r2,
},
}
let self_repo = self.repo.as_ref();
let other_repo = other.repo.as_ref();
// iff both packages have repos, they must be identical, otherwise we don't care
let repos_are_identical =
self_repo.map_or(true, |sr| other_repo.map_or(true, |or| sr == or));
let names_are_identical = self.name == other.name;
names_are_identical && repos_are_identical
}
}
+3 -3
View File
@@ -2,13 +2,13 @@ use std::{env, path::PathBuf};
use anyhow::{Context, Result};
pub(crate) fn get_pacdef_group_dir() -> Result<PathBuf> {
pub fn get_pacdef_group_dir() -> Result<PathBuf> {
let mut result = get_pacdef_base_dir().context("getting pacdef base dir")?;
result.push("groups");
Ok(result)
}
pub(crate) fn get_pacdef_base_dir() -> Result<PathBuf> {
pub fn get_pacdef_base_dir() -> Result<PathBuf> {
let mut dir = get_xdg_config_home().context("getting XDG_CONFIG_HOME")?;
dir.push("pacdef");
Ok(dir)
@@ -24,6 +24,6 @@ fn get_xdg_config_home() -> Result<PathBuf> {
}
}
pub(crate) fn get_home_dir() -> Result<PathBuf> {
pub fn get_home_dir() -> Result<PathBuf> {
Ok(env::var("HOME").context("getting $HOME variable")?.into())
}
+1 -1
View File
@@ -10,7 +10,7 @@ use crate::grouping::{Group, Package, Section};
pub const NO_PACKAGES_FOUND: &str = "no packages matching query";
pub(crate) fn search_packages(args: &ArgMatches, groups: &HashSet<Group>) -> Result<()> {
pub fn search_packages(args: &ArgMatches, groups: &HashSet<Group>) -> Result<()> {
let search_string = args
.get_one::<String>("string")
.context("getting search string from arg")?;
+2 -2
View File
@@ -3,7 +3,7 @@ use std::io::{self, Read, Write};
use anyhow::{Context, Result};
use termios::*;
pub(crate) fn get_user_confirmation() -> Result<bool> {
pub fn get_user_confirmation() -> Result<bool> {
print!("Continue? [Y/n] ");
std::io::stdout().flush().context("flushing stdout")?;
@@ -15,7 +15,7 @@ pub(crate) fn get_user_confirmation() -> Result<bool> {
Ok(reply.trim().is_empty() || reply.to_lowercase().contains('y'))
}
pub(crate) fn read_single_char_from_terminal() -> Result<char> {
pub fn read_single_char_from_terminal() -> Result<char> {
// 0 is the file descriptor for stdin
let fd = 0;
let termios = Termios::from_fd(fd).context("getting stdin fd")?;