mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-06 19:45:20 +01:00
Fix bug in removing used parameters
The current implementation removes parameters if they are used - however, it only removes the first instance, and removes instances by index. However, when multiple items are being removed, following indices must be decremented by 1 to account for previously removed items.
This commit is contained in:
@@ -670,15 +670,8 @@ else {
|
||||
}
|
||||
## Remove all used parameters
|
||||
{
|
||||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(${len(replacements)});
|
||||
for param_name in [${', '.join(reversed(['"%s"' % r[1] for r in replacements]))}].iter() {
|
||||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||||
indices_for_removal.push(index);
|
||||
}
|
||||
}
|
||||
for &index in indices_for_removal.iter() {
|
||||
params.remove(index);
|
||||
}
|
||||
let to_remove = [${', '.join(reversed(['"%s"' % r[1] for r in replacements]))}];
|
||||
params.retain(|(n, _)| !to_remove.contains(n));
|
||||
}
|
||||
% endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user