mem::replace -> mem::take

This commit is contained in:
Vadim Petrochenkov
2020-10-03 20:33:03 +03:00
committed by Emilio Cobos Álvarez
parent f3d5a20363
commit ea919a4edf
3 changed files with 12 additions and 10 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ impl Function {
.unwrap_or(config.function.rename_args);
if let Some(r) = rules.not_none() {
let args = std::mem::replace(&mut self.args, vec![]);
let args = std::mem::take(&mut self.args);
self.args = args
.into_iter()
.map(|arg| {
+6 -4
View File
@@ -78,15 +78,17 @@ pub struct ItemMap<T: Item> {
data: IndexMap<Path, ItemValue<T>>,
}
impl<T: Item + Clone> ItemMap<T> {
pub fn default() -> ItemMap<T> {
impl<T: Item> Default for ItemMap<T> {
fn default() -> ItemMap<T> {
ItemMap {
data: Default::default(),
}
}
}
impl<T: Item + Clone> ItemMap<T> {
pub fn rebuild(&mut self) {
let old = mem::replace(self, ItemMap::default());
let old = mem::take(self);
old.for_all_items(|x| {
self.try_insert(x.clone());
});
@@ -150,7 +152,7 @@ impl<T: Item + Clone> ItemMap<T> {
where
F: Fn(&T) -> bool,
{
let data = mem::replace(&mut self.data, Default::default());
let data = mem::take(&mut self.data);
for (name, container) in data {
match container {
+5 -5
View File
@@ -87,22 +87,22 @@ impl Monomorphs {
}
pub fn drain_opaques(&mut self) -> Vec<OpaqueItem> {
mem::replace(&mut self.opaques, Vec::new())
mem::take(&mut self.opaques)
}
pub fn drain_structs(&mut self) -> Vec<Struct> {
mem::replace(&mut self.structs, Vec::new())
mem::take(&mut self.structs)
}
pub fn drain_unions(&mut self) -> Vec<Union> {
mem::replace(&mut self.unions, Vec::new())
mem::take(&mut self.unions)
}
pub fn drain_typedefs(&mut self) -> Vec<Typedef> {
mem::replace(&mut self.typedefs, Vec::new())
mem::take(&mut self.typedefs)
}
pub fn drain_enums(&mut self) -> Vec<Enum> {
mem::replace(&mut self.enums, Vec::new())
mem::take(&mut self.enums)
}
}