Reduce usage of Default::default() to make it easier to refactor.
This commit is contained in:
@@ -116,7 +116,7 @@ pub fn from_dynamic<'de, T: Deserialize<'de>>(
|
||||
|
||||
impl Error for Box<EvalAltResult> {
|
||||
fn custom<T: fmt::Display>(err: T) -> Self {
|
||||
LexError::ImproperSymbol(Default::default(), err.to_string())
|
||||
LexError::ImproperSymbol(String::new(), err.to_string())
|
||||
.into_err(Position::NONE)
|
||||
.into()
|
||||
}
|
||||
|
@@ -168,7 +168,7 @@ impl From<&crate::module::FuncInfo> for FnMetadata {
|
||||
.to_vec()
|
||||
}
|
||||
} else {
|
||||
Default::default()
|
||||
Vec::new()
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ impl From<crate::ast::ScriptFnMetadata<'_>> for FnMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize)]
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ModuleMetadata {
|
||||
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
|
||||
@@ -210,7 +210,10 @@ struct ModuleMetadata {
|
||||
impl ModuleMetadata {
|
||||
#[inline(always)]
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
Self {
|
||||
modules: BTreeMap::new(),
|
||||
functions: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,6 +284,6 @@ impl Engine {
|
||||
/// 2) Functions in static modules
|
||||
/// 3) Functions in global modules (optional)
|
||||
pub fn gen_fn_metadata_to_json(&self, include_global: bool) -> serde_json::Result<String> {
|
||||
self.gen_fn_metadata_with_ast_to_json(&Default::default(), include_global)
|
||||
self.gen_fn_metadata_with_ast_to_json(&AST::empty(), include_global)
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ impl DynamicSerializer {
|
||||
#[must_use]
|
||||
pub fn new(_value: Dynamic) -> Self {
|
||||
Self {
|
||||
_key: Default::default(),
|
||||
_key: Dynamic::UNIT,
|
||||
_value,
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ impl DynamicSerializer {
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn to_dynamic<T: Serialize>(value: T) -> RhaiResult {
|
||||
let mut s = DynamicSerializer::new(Default::default());
|
||||
let mut s = DynamicSerializer::new(Dynamic::UNIT);
|
||||
value.serialize(&mut s)
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ impl Serializer for &mut DynamicSerializer {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
return Ok(StructVariantSerializer {
|
||||
variant: _variant,
|
||||
map: Default::default(),
|
||||
map: Map::new(),
|
||||
});
|
||||
#[cfg(feature = "no_object")]
|
||||
return Err(EvalAltResult::ErrorMismatchDataType(
|
||||
|
Reference in New Issue
Block a user