Reduce size of Variant trait.

This commit is contained in:
Stephen Chung
2022-01-01 19:54:46 +08:00
parent a6ddb64596
commit d60ed5a502
6 changed files with 38 additions and 46 deletions

View File

@@ -61,7 +61,7 @@ pub trait FuncArgs {
impl<T: Variant + Clone> FuncArgs for Vec<T> {
#[inline]
fn parse<ARGS: Extend<Dynamic>>(self, args: &mut ARGS) {
args.extend(self.into_iter().map(Variant::into_dynamic));
args.extend(self.into_iter().map(Dynamic::from));
}
}
@@ -75,7 +75,7 @@ macro_rules! impl_args {
#[allow(unused_variables)]
fn parse<ARGS: Extend<Dynamic>>(self, args: &mut ARGS) {
let ($($p,)*) = self;
$(args.extend(Some($p.into_dynamic()));)*
$(args.extend(Some(Dynamic::from($p)));)*
}
}

View File

@@ -135,7 +135,7 @@ macro_rules! def_register {
let r = self($($arg),*);
// Map the result
Ok(r.into_dynamic())
Ok(Dynamic::from(r))
}) as Box<FnAny>)
}
}
@@ -163,7 +163,7 @@ macro_rules! def_register {
let r = self(ctx, $($arg),*);
// Map the result
Ok(r.into_dynamic())
Ok(Dynamic::from(r))
}) as Box<FnAny>)
}
}