Skip to content

Commit

Permalink
style: refactor to adhere to clippy::field_reassign_with_default
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoniePhiline committed Nov 21, 2024
1 parent f1f6b1b commit 23adb4e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
18 changes: 12 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,26 @@ mod test {
fn should_query_ssh_config() {
let mut config = SshConfig::default();
// add config
let mut params1 = HostParams::default();
params1.bind_address = Some(String::from("0.0.0.0"));
let mut params1 = HostParams {
bind_address: Some(String::from("0.0.0.0")),
..Default::default()
};
config.hosts.push(Host::new(
vec![HostClause::new(String::from("192.168.*.*"), false)],
params1.clone(),
));
let mut params2 = HostParams::default();
params2.bind_interface = Some(String::from("tun0"));
let params2 = HostParams {
bind_interface: Some(String::from("tun0")),
..Default::default()
};
config.hosts.push(Host::new(
vec![HostClause::new(String::from("192.168.10.*"), false)],
params2.clone(),
));
let mut params3 = HostParams::default();
params3.host_name = Some(String::from("172.26.104.4"));
let params3 = HostParams {
host_name: Some(String::from("172.26.104.4")),
..Default::default()
};
config.hosts.push(Host::new(
vec![
HostClause::new(String::from("172.26.*.*"), false),
Expand Down
50 changes: 25 additions & 25 deletions src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,31 +246,31 @@ mod test {
#[test]
fn should_merge_params() {
let mut params = HostParams::default();
let mut b = HostParams::default();
b.bind_address = Some(String::from("pippo"));
b.bind_interface = Some(String::from("tun0"));
b.ca_signature_algorithms = Some(vec![]);
b.certificate_file = Some(PathBuf::default());
b.ciphers = Some(vec![]);
b.compression = Some(true);
b.connect_timeout = Some(Duration::from_secs(1));
b.connection_attempts = Some(3);
b.host_key_algorithms = Some(vec![]);
b.host_name = Some(String::from("192.168.1.2"));
b.identity_file = Some(vec![PathBuf::default()]);
b.ignore_unknown = Some(vec![]);
b.kex_algorithms = Some(vec![]);
b.mac = Some(vec![]);
b.port = Some(22);
b.pubkey_accepted_algorithms = Some(vec![]);
b.pubkey_authentication = Some(true);
b.remote_forward = Some(32);
b.server_alive_interval = Some(Duration::from_secs(10));
#[cfg(target_os = "macos")]
{
b.use_keychain = Some(true);
}
b.tcp_keep_alive = Some(true);
let mut b = HostParams {
bind_address: Some(String::from("pippo")),
bind_interface: Some(String::from("tun0")),
ca_signature_algorithms: Some(vec![]),
certificate_file: Some(PathBuf::default()),
ciphers: Some(vec![]),
compression: Some(true),
connect_timeout: Some(Duration::from_secs(1)),
connection_attempts: Some(3),
host_key_algorithms: Some(vec![]),
host_name: Some(String::from("192.168.1.2")),
identity_file: Some(vec![PathBuf::default()]),
ignore_unknown: Some(vec![]),
kex_algorithms: Some(vec![]),
mac: Some(vec![]),
port: Some(22),
pubkey_accepted_algorithms: Some(vec![]),
pubkey_authentication: Some(true),
remote_forward: Some(32),
server_alive_interval: Some(Duration::from_secs(10)),
#[cfg(target_os = "macos")]
use_keychain: Some(true),
tcp_keep_alive: Some(true),
..Default::default()
};
params.merge(&b);
assert!(params.bind_address.is_some());
assert!(params.bind_interface.is_some());
Expand Down

0 comments on commit 23adb4e

Please sign in to comment.