mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
Merge pull request #2481 from kolloch/feature/no-clone-in-insert
Input.insert: No need to clone
This commit is contained in:
commit
a4b9bfc97b
1 changed files with 5 additions and 7 deletions
|
@ -67,13 +67,11 @@ impl Input {
|
|||
/// Insert some items to the Input items just after current parsing cursor.
|
||||
/// Usually used by replaced items recovering.
|
||||
pub(crate) fn insert(&mut self, insert_items: &[&str]) {
|
||||
self.items = {
|
||||
let mut new_items: Vec<OsString> = insert_items.iter().map(OsString::from).collect();
|
||||
for unparsed_item in &self.items[self.cursor..] {
|
||||
new_items.push(unparsed_item.clone());
|
||||
}
|
||||
new_items
|
||||
};
|
||||
self.items = insert_items
|
||||
.iter()
|
||||
.map(OsString::from)
|
||||
.chain(self.items.drain(self.cursor..))
|
||||
.collect();
|
||||
self.cursor = 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue