Use mem::take instead of mem::replace where appropriate (#5846)

* replace replace with take

* Update client/api/src/cht.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/api/src/cht.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Nikolay Volf
2020-04-30 15:53:36 +03:00
committed by GitHub
parent c3a6d8a881
commit c09bb1f350
11 changed files with 21 additions and 21 deletions
+2 -2
View File
@@ -114,7 +114,7 @@ impl<H, N, V> ForkTree<H, N, V> where
)?;
let removed = if let Some(mut root_index) = new_root_index {
let mut old_roots = std::mem::replace(&mut self.roots, Vec::new());
let mut old_roots = std::mem::take(&mut self.roots);
let mut root = None;
let mut cur_children = Some(&mut old_roots);
@@ -137,7 +137,7 @@ impl<H, N, V> ForkTree<H, N, V> where
// we found the deepest ancestor of the finalized block, so we prune
// out any children that don't include the finalized block.
let root_children = std::mem::replace(&mut root.children, Vec::new());
let root_children = std::mem::take(&mut root.children);
let mut is_first = true;
for child in root_children {