mirror of
https://github.com/vrc-get/vrc-get.git
synced 2026-06-21 09:58:08 +00:00
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:
parent
334492e5c6
commit
800278a0c3
1 changed files with 8 additions and 10 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue