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

@@ -201,13 +201,7 @@ pub struct AST {
impl Default for AST {
#[inline(always)]
fn default() -> Self {
Self {
source: None,
body: Default::default(),
functions: Default::default(),
#[cfg(not(feature = "no_module"))]
resolver: None,
}
Self::new_empty()
}
}
@@ -227,6 +221,18 @@ impl AST {
resolver: None,
}
}
/// Create an empty [`AST`].
#[inline]
#[must_use]
pub fn new_empty() -> Self {
Self {
source: None,
body: Default::default(),
functions: Default::default(),
#[cfg(not(feature = "no_module"))]
resolver: None,
}
}
/// Create a new [`AST`] with a source name.
#[inline(always)]
#[must_use]