rework section loading

This commit is contained in:
timeshifter
2023-01-09 19:06:51 +01:00
parent 45f8f9a5d5
commit 03cc060d0f
8 changed files with 32 additions and 14 deletions
+3 -3
View File
@@ -13,7 +13,7 @@ impl Section {
Self { name, packages }
}
pub fn from_lines<'a>(iter: &mut impl Iterator<Item = &'a str>) -> Self {
pub fn from_lines<'a>(iter: &mut (impl Iterator<Item = &'a str> + std::fmt::Debug)) -> Self {
let name = iter
.find(|line| line.starts_with('['))
.unwrap()
@@ -24,8 +24,8 @@ impl Section {
let packages = iter
.take_while(|line| !line.starts_with('['))
.filter(|line| !line.contains(char::is_alphabetic))
.map(Package::from)
.map(Package::try_from)
.filter_map(|p| p.ok())
.collect();
Self::new(name, packages)