simplify by using mem::swap instead of mem::take
This commit is contained in:
parent
02efd09d80
commit
5ce9f78103
@ -122,32 +122,22 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
let scope = self.eval_args(fn_args, args)?;
|
let scope = self.eval_args(fn_args, args)?;
|
||||||
|
|
||||||
let mut new_scope = std::mem::take(self.content_scopes);
|
if declared_at_root {
|
||||||
|
mem::swap(self.scopes, self.content_scopes);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.scopes.enter_scope(scope);
|
||||||
|
|
||||||
self.content.push(Content {
|
self.content.push(Content {
|
||||||
content,
|
content,
|
||||||
content_args,
|
content_args,
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut scopes = if declared_at_root {
|
|
||||||
mem::take(&mut new_scope)
|
|
||||||
} else {
|
|
||||||
mem::take(self.scopes)
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut content_scopes = if declared_at_root {
|
|
||||||
mem::take(self.scopes)
|
|
||||||
} else {
|
|
||||||
mem::take(&mut new_scope)
|
|
||||||
};
|
|
||||||
|
|
||||||
scopes.enter_scope(scope);
|
|
||||||
|
|
||||||
let body = Parser {
|
let body = Parser {
|
||||||
toks: &mut body.into_iter().peekmore(),
|
toks: &mut body.into_iter().peekmore(),
|
||||||
map: self.map,
|
map: self.map,
|
||||||
path: self.path,
|
path: self.path,
|
||||||
scopes: &mut scopes,
|
scopes: self.scopes,
|
||||||
global_scope: self.global_scope,
|
global_scope: self.global_scope,
|
||||||
super_selectors: self.super_selectors,
|
super_selectors: self.super_selectors,
|
||||||
span_before: self.span_before,
|
span_before: self.span_before,
|
||||||
@ -156,18 +146,15 @@ impl<'a> Parser<'a> {
|
|||||||
at_root: false,
|
at_root: false,
|
||||||
at_root_has_selector: self.at_root_has_selector,
|
at_root_has_selector: self.at_root_has_selector,
|
||||||
extender: self.extender,
|
extender: self.extender,
|
||||||
content_scopes: &mut content_scopes,
|
content_scopes: self.content_scopes,
|
||||||
}
|
}
|
||||||
.parse()?;
|
.parse()?;
|
||||||
|
|
||||||
self.content.pop();
|
self.content.pop();
|
||||||
if declared_at_root {
|
if declared_at_root {
|
||||||
*self.scopes = content_scopes;
|
mem::swap(self.scopes, self.content_scopes);
|
||||||
*self.content_scopes = scopes;
|
|
||||||
} else {
|
} else {
|
||||||
scopes.exit_scope();
|
self.scopes.exit_scope();
|
||||||
*self.scopes = scopes;
|
|
||||||
*self.content_scopes = content_scopes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(body)
|
Ok(body)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user