refactor mixin args
@@ -62,7 +62,7 @@ impl Mixin {
scope: &Scope,
super_selector: &Selector,
) -> SassResult<Mixin> {
- for (idx, arg) in self.args.0.iter().enumerate() {
+ for (idx, arg) in self.args.0.iter_mut().enumerate() {
if arg.is_variadic {
let span = args.span();
self.scope.insert_var(
@@ -74,14 +74,12 @@ impl Mixin {
)?;
break;
}
- let val = match args.get_positional(idx, scope, super_selector) {
+ let val = match args.get(idx, arg.name.clone(), &scope, super_selector) {
Some(v) => v?,
- None => match args.get_named(arg.name.clone(), scope, super_selector) {
- Some(v) => v?,
- None => match &arg.default {
+ None => match arg.default.as_mut() {
Some(v) => Value::from_tokens(
- &mut v.iter().cloned().peekmore(),
- scope,
+ &mut std::mem::take(v).into_iter().peekmore(),
+ &scope,
super_selector,
)?,
None => {
@@ -90,7 +88,6 @@ impl Mixin {
)
}
},
- },
};
self.scope.insert_var(&arg.name, val)?;
}
