From 6c3e477d134511094ab301fc15c504cc79804e41 Mon Sep 17 00:00:00 2001 From: Charles Gleason Date: Tue, 28 Jan 2020 11:59:50 -0500 Subject: [PATCH] Reformat truncation section of clone_from --- src/liballoc/collections/btree/map.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index d0c56d83d722a..7c45a6fe49823 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -227,20 +227,20 @@ impl BTreeClone for BTreeMap { fn clone_from(&mut self, other: &Self) { // This truncates `self` to `other.len()` by calling `split_off` on // the first key after `other.len()` elements if it exists - if let Some(key) = { - if self.len() > other.len() { - let diff = self.len() - other.len(); - if diff <= other.len() { - self.iter().nth_back(diff - 1).map(|pair| (*pair.0).clone()) - } else { - self.iter().nth(other.len()).map(|pair| (*pair.0).clone()) - } + let split_off_key = if self.len() > other.len() { + let diff = self.len() - other.len(); + if diff <= other.len() { + self.iter().nth_back(diff - 1).map(|pair| (*pair.0).clone()) } else { - None + self.iter().nth(other.len()).map(|pair| (*pair.0).clone()) } - } { + } else { + None + }; + if let Some(key) = split_off_key { self.split_off(&key); } + let mut siter = self.range_mut(..); let mut oiter = other.iter(); // After truncation, `self` is at most as long as `other` so this loop