[system/kconfigeditor] src: Use flat_map instead of map+flatten
Nicolas Fella <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 89eefade8a7d1b6667ef552a70dcfcb42f2aadb4 by Nicolas Fella.
Committed on 23/07/2026 at 14:27.
Pushed by nicolasfella into branch 'master'.
Use flat_map instead of map+flatten
M +1 -2 src/entrymodel.rs
M +3 -6 src/filesmodel.rs
M +1 -2 src/groupsmodel.rs
https://invent.kde.org/system/kconfigeditor/-/commit/89eefade8a7d1b6667ef552a70dcfcb42f2aadb4
diff --git a/src/entrymodel.rs b/src/entrymodel.rs
index 7b2f27f..a9768f0 100644
--- a/src/entrymodel.rs
+++ b/src/entrymodel.rs
@@ -566,8 +566,7 @@ impl entrymodel::EntryModel {
let configs: Vec<_> = Upcast::<QList<QString>>::upcast(&kcfg_files)
.iter()
- .map(|path| config::parse(&path.to_string().as_str()))
- .flatten()
+ .flat_map(|path| config::parse(&path.to_string().as_str()))
.filter(|config| config.kcfgfile.as_ref().is_some())
.filter(|config| {
config
diff --git a/src/filesmodel.rs b/src/filesmodel.rs
index ea66548..179ff02 100644
--- a/src/filesmodel.rs
+++ b/src/filesmodel.rs
@@ -120,17 +120,14 @@ impl filesmodel::FilesModel {
let configs: Vec<_> = Upcast::<QList<QString>>::upcast(&kcfg_files)
.iter()
- .map(|path| config::parse(path.to_string().as_str()))
- .flatten()
+ .flat_map(|path| config::parse(path.to_string().as_str()))
.collect();
apps.extend(
configs
.iter()
- .map(|kcfg| kcfg.kcfgfile.clone())
- .flatten()
- .map(|file| file.name)
- .flatten()
+ .flat_map(|kcfg| kcfg.kcfgfile.clone())
+ .flat_map(|file| file.name)
.collect::<HashSet<_>>()
.iter()
.map(|s| QString::from(s))
diff --git a/src/groupsmodel.rs b/src/groupsmodel.rs
index 5aa326f..8d90533 100644
--- a/src/groupsmodel.rs
+++ b/src/groupsmodel.rs
@@ -132,8 +132,7 @@ impl groupsmodel::GroupsModel {
let configs: Vec<_> = Upcast::<QList<QString>>::upcast(&kcfg_files)
.iter()
- .map(|path| config::parse(path.to_string().as_str()))
- .flatten()
+ .flat_map(|path| config::parse(path.to_string().as_str()))
.filter(|config| config.kcfgfile.as_ref().is_some())
.filter(|config| {
config