Reduce usage of Default::default()

This commit is contained in:
Stephen Chung
2021-09-11 19:40:40 +08:00
parent 5d3a22ab6f
commit 6510b617fe
14 changed files with 59 additions and 45 deletions

View File

@@ -207,6 +207,13 @@ struct ModuleMetadata {
pub functions: Vec<FnMetadata>,
}
impl ModuleMetadata {
#[inline(always)]
pub fn new() -> Self {
Default::default()
}
}
impl From<&crate::Module> for ModuleMetadata {
fn from(module: &crate::Module) -> Self {
let mut functions: Vec<_> = module.iter_fn().map(|f| f.into()).collect();
@@ -239,7 +246,7 @@ impl Engine {
include_global: bool,
) -> serde_json::Result<String> {
let _ast = ast;
let mut global: ModuleMetadata = Default::default();
let mut global = ModuleMetadata::new();
if include_global {
self.global_modules