mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Avoid using ..Default::default()
Exhaustively naming fields means I can't forget to set sensible values in cases where Default::default() might not produce them.
This commit is contained in:
@@ -32,7 +32,10 @@ impl File {
|
||||
pub fn new(name: String) -> Self {
|
||||
Self {
|
||||
name: Filename::new(name),
|
||||
..Default::default()
|
||||
display_name: None,
|
||||
detail: Box::default(),
|
||||
condition: None,
|
||||
constraint: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ impl Group {
|
||||
pub fn new(name: String) -> Self {
|
||||
Self {
|
||||
name: name.into_boxed_str(),
|
||||
..Default::default()
|
||||
description: None,
|
||||
after_groups: Box::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ impl Location {
|
||||
pub fn new(url: String) -> Self {
|
||||
Location {
|
||||
url: url.into_boxed_str(),
|
||||
..Default::default()
|
||||
name: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ impl MessageContent {
|
||||
pub fn new(text: String) -> Self {
|
||||
MessageContent {
|
||||
text: text.into_boxed_str(),
|
||||
..Default::default()
|
||||
language: MessageContent::DEFAULT_LANGUAGE.into(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,12 @@ impl PluginCleaningData {
|
||||
pub fn new(crc: u32, cleaning_utility: String) -> Self {
|
||||
Self {
|
||||
crc,
|
||||
itm_count: 0,
|
||||
deleted_reference_count: 0,
|
||||
deleted_navmesh_count: 0,
|
||||
cleaning_utility: cleaning_utility.into_boxed_str(),
|
||||
..Default::default()
|
||||
detail: Box::default(),
|
||||
condition: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +42,30 @@ impl PluginMetadata {
|
||||
pub fn new(name: &str) -> Result<Self, RegexError> {
|
||||
Ok(Self {
|
||||
name: PluginName::new(name)?,
|
||||
..Default::default()
|
||||
group: None,
|
||||
load_after: Box::default(),
|
||||
requirements: Box::default(),
|
||||
incompatibilities: Box::default(),
|
||||
messages: Box::default(),
|
||||
tags: Box::default(),
|
||||
dirty_info: Box::default(),
|
||||
clean_info: Box::default(),
|
||||
locations: Box::default(),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn with_same_name(metadata: &PluginMetadata) -> Self {
|
||||
Self {
|
||||
name: metadata.name.clone(),
|
||||
..Default::default()
|
||||
group: None,
|
||||
load_after: Box::default(),
|
||||
requirements: Box::default(),
|
||||
incompatibilities: Box::default(),
|
||||
messages: Box::default(),
|
||||
tags: Box::default(),
|
||||
dirty_info: Box::default(),
|
||||
clean_info: Box::default(),
|
||||
locations: Box::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -26,7 +26,13 @@ mod test {
|
||||
pub(super) fn new(name: &str) -> Self {
|
||||
Self {
|
||||
name: name.to_owned(),
|
||||
..Default::default()
|
||||
masters: Vec::new(),
|
||||
is_master: false,
|
||||
is_blueprint_plugin: false,
|
||||
override_record_count: 0,
|
||||
asset_count: 0,
|
||||
overlapping_record_plugins: Vec::new(),
|
||||
overlapping_asset_plugins: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ impl Vertex {
|
||||
pub fn new(name: String) -> Self {
|
||||
Self {
|
||||
name,
|
||||
..Default::default()
|
||||
out_edge_type: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user