fmt, clippy

This commit is contained in:
2026-08-23 01:46:04 +02:00
parent c2e1288bc5
commit 4a8ff9ac0d
11 changed files with 108 additions and 56 deletions
+21 -8
View File
@@ -6,7 +6,7 @@ use std::collections::{HashMap, HashSet, VecDeque};
use std::path::Path;
use crate::debian::checksums::FileChecksums;
use crate::debian::control::{parse_paragraphs, write_paragraph, Paragraph};
use crate::debian::control::{Paragraph, parse_paragraphs, write_paragraph};
/// One installed package relevant for dependency resolution.
#[derive(Debug, Clone)]
@@ -52,13 +52,20 @@ impl StatusDb {
};
let arch = para.get("Architecture").unwrap_or("").to_string();
if let (Some(version), false) = (para.get("Version"), arch.is_empty()) {
db.pkgs.entry(package.to_string()).or_default().push(InstalledPkg {
version: version.to_string(),
arch: arch.clone(),
});
db.pkgs
.entry(package.to_string())
.or_default()
.push(InstalledPkg {
version: version.to_string(),
arch: arch.clone(),
});
}
if para.get("Essential").map(|v| v.eq_ignore_ascii_case("yes")).unwrap_or(false) {
if para
.get("Essential")
.map(|v| v.eq_ignore_ascii_case("yes"))
.unwrap_or(false)
{
db.essential.push(package.to_string());
}
@@ -291,7 +298,10 @@ pub fn render_buildinfo(input: &BuildInfoInput) -> Paragraph {
}
/// Serialize and atomically write a `.buildinfo` file.
pub fn save_buildinfo(path: &Path, paragraph: &Paragraph) -> Result<(), Box<dyn std::error::Error>> {
pub fn save_buildinfo(
path: &Path,
paragraph: &Paragraph,
) -> Result<(), Box<dyn std::error::Error>> {
let tmp = path.with_extension("new");
std::fs::write(&tmp, write_paragraph(paragraph))
.map_err(|e| format!("cannot write '{}': {}", tmp.display(), e))?;
@@ -366,7 +376,10 @@ Architecture: amd64
#[test]
fn wrap_binary_field() {
assert_eq!(wrap_long("abc"), "abc");
let long = (0..500).map(|i| i.to_string()).collect::<Vec<_>>().join(" ");
let long = (0..500)
.map(|i| i.to_string())
.collect::<Vec<_>>()
.join(" ");
let wrapped = wrap_long(&long);
assert!(wrapped.contains('\n'));
for line in wrapped.lines() {