style(vpm): satisfy fmt and clippy on reorder_user_repos_by_indices

Auto-applied cargo fmt for the collect-chain split, then folded the
nested `if let` into a let-chain and replaced the manual `if let Some`
loop with `into_iter().flatten()`.
This commit is contained in:
nekochanfood 2026-05-30 14:55:43 +09:00
commit 800278a0c3

View file

@ -165,21 +165,19 @@ impl VpmSettings {
}
pub fn reorder_user_repos_by_indices(&mut self, indices: &[usize]) {
let mut pool: Vec<Option<UserRepoSetting>> =
std::mem::take(&mut self.parsed.user_repos).into_iter().map(Some).collect();
let mut pool: Vec<Option<UserRepoSetting>> = std::mem::take(&mut self.parsed.user_repos)
.into_iter()
.map(Some)
.collect();
let mut result = Vec::with_capacity(pool.len());
for &idx in indices {
if let Some(slot) = pool.get_mut(idx) {
if let Some(repo) = slot.take() {
result.push(repo);
}
}
}
for slot in pool {
if let Some(repo) = slot {
if let Some(slot) = pool.get_mut(idx)
&& let Some(repo) = slot.take()
{
result.push(repo);
}
}
result.extend(pool.into_iter().flatten());
self.parsed.user_repos = result;
}