Fix some clippy lints

This commit is contained in:
Nathan Fisher 2023-03-25 17:04:50 -04:00
parent 26af277e28
commit 9d53c9f44d
4 changed files with 25 additions and 25 deletions

View File

@ -33,8 +33,7 @@ fn create(matches: &ArgMatches) -> Result<(), Box<dyn Error>> {
let mut specs = if let Some(s) = matches.get_one::<String>("specs") { let mut specs = if let Some(s) = matches.get_one::<String>("specs") {
let path = PathBuf::from(s.to_string()); let path = PathBuf::from(s.to_string());
let fd = File::open(path)?; let fd = File::open(path)?;
let specs = ron::de::from_reader(fd)?; ron::de::from_reader(fd)?
specs
} else { } else {
Specs::default() Specs::default()
}; };

View File

@ -67,7 +67,7 @@ impl Item {
fn fix_path(path: &Path) -> PathBuf { fn fix_path(path: &Path) -> PathBuf {
let path = if let Ok(p) = path.strip_prefix("./") { let path = if let Ok(p) = path.strip_prefix("./") {
&p p
} else { } else {
path path
}; };

View File

@ -69,18 +69,19 @@ pub struct Package {
impl From<Specs> for Package { impl From<Specs> for Package {
fn from(value: Specs) -> Self { fn from(value: Specs) -> Self {
let mut package = Package::default(); Package {
package.name = value.name; name: value.name,
package.version = value.version; version: value.version,
package.release = value.release; release: value.release,
package.description = value.description; description: value.description,
package.long_description = value.long_description; long_description: value.long_description,
package.appstream_data = value.appstream_data; appstream_data: value.appstream_data,
package.dependencies = value.dependencies; dependencies: value.dependencies,
package.users = value.users; users: value.users,
package.groups = value.groups; groups: value.groups,
package.post_install = value.post_install; post_install: value.post_install,
package ..Default::default()
}
} }
} }
@ -133,14 +134,14 @@ pub fn create(path: &Path, specs: Specs, outdir: &Path) -> Result<(), Box<dyn Er
let mut archive = vec![]; let mut archive = vec![];
let mut totalsize = 0; let mut totalsize = 0;
while let Some(item) = items.pop() { while let Some(item) = items.pop() {
match &item.entry { if let Entry::File {
Entry::File {
path: _, path: _,
sha256sum: _, sha256sum: _,
mode: _, mode: _,
size, size,
} => totalsize += size, } = &item.entry
_ => {} {
totalsize += size;
} }
plist.entries.push(item.entry); plist.entries.push(item.entry);
archive.extend(item.data); archive.extend(item.data);
@ -153,7 +154,7 @@ pub fn create(path: &Path, specs: Specs, outdir: &Path) -> Result<(), Box<dyn Er
let name = package.fullname(); let name = package.fullname();
let mut path = PathBuf::from(&name); let mut path = PathBuf::from(&name);
path.set_extension("tar.zst"); path.set_extension("tar.zst");
let mut outfile = outdir.to_path_buf(); let mut outfile = outdir;
outfile.push(path); outfile.push(path);
let fd = File::create(&outfile)?; let fd = File::create(&outfile)?;
let mut writer = Encoder::new(fd, 0)?; let mut writer = Encoder::new(fd, 0)?;

View File

@ -51,7 +51,7 @@ impl fmt::Display for Version {
} }
Self::Git { hash, datetime } => { Self::Git { hash, datetime } => {
let v = GitRev { let v = GitRev {
hash: hash.to_owned(), hash: hash.clone(),
datetime: *datetime, datetime: *datetime,
}; };
write!(f, "{v}") write!(f, "{v}")