Construct structs with ..default() to avoid a lint

This commit is contained in:
teor 2021-01-19 06:40:15 +10:00 committed by Deirdre Connolly
parent b1d28b73fd
commit eadbea1423
2 changed files with 16 additions and 10 deletions

View File

@ -110,11 +110,12 @@ impl Config {
(path, opts) (path, opts)
} }
/// Construct a config for an ephemeral in memory database /// Construct a config for an ephemeral database
pub fn ephemeral() -> Self { pub fn ephemeral() -> Config {
let mut config = Self::default(); Config {
config.ephemeral = true; ephemeral: true,
config ..Config::default()
}
} }
/// Calculate the database's share of `open_file_limit` /// Calculate the database's share of `open_file_limit`

View File

@ -39,11 +39,16 @@ use zebrad::config::ZebradConfig;
const LAUNCH_DELAY: Duration = Duration::from_secs(3); const LAUNCH_DELAY: Duration = Duration::from_secs(3);
fn default_test_config() -> Result<ZebradConfig> { fn default_test_config() -> Result<ZebradConfig> {
let mut config = ZebradConfig::default(); let auto_port_ipv4_local = zebra_network::Config {
config.state = zebra_state::Config::ephemeral(); listen_addr: "127.0.0.1:0".parse()?,
config.network.listen_addr = "127.0.0.1:0".parse()?; ..zebra_network::Config::default()
};
Ok(config) let local_ephemeral = ZebradConfig {
state: zebra_state::Config::ephemeral(),
network: auto_port_ipv4_local,
..ZebradConfig::default()
};
Ok(local_ephemeral)
} }
fn persistent_test_config() -> Result<ZebradConfig> { fn persistent_test_config() -> Result<ZebradConfig> {