From bfe6345bbef9fbf3baf6299c0cf26d4ae6653205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Thu, 13 Jul 2023 10:32:42 +0100 Subject: [PATCH 1/2] Apply suggestions from Clippy --- rust/agama-cli/src/printers.rs | 1 - rust/agama-cli/src/profile.rs | 2 +- rust/agama-cli/src/progress.rs | 4 ++-- rust/agama-dbus-server/src/locale.rs | 9 ++++----- .../src/network/dbus/interfaces.rs | 8 ++++---- rust/agama-dbus-server/src/network/dbus/service.rs | 2 +- rust/agama-dbus-server/src/network/dbus/tree.rs | 12 ++++++------ rust/agama-dbus-server/src/network/error.rs | 2 +- rust/agama-dbus-server/src/network/model.rs | 12 +++++------- rust/agama-dbus-server/src/network/nm/adapter.rs | 11 +++-------- rust/agama-dbus-server/src/network/nm/client.rs | 2 +- rust/agama-dbus-server/src/network/nm/dbus.rs | 8 ++++---- rust/agama-dbus-server/src/network/nm/model.rs | 14 ++++---------- rust/agama-dbus-server/src/questions.rs | 4 ++-- rust/agama-lib/src/network/client.rs | 8 ++++---- rust/agama-lib/src/network/store.rs | 7 ++----- rust/agama-lib/src/network/types.rs | 4 ++-- rust/agama-lib/src/profile.rs | 4 ++-- rust/agama-lib/src/settings.rs | 4 ++-- rust/agama-lib/src/software/store.rs | 2 +- rust/agama-lib/src/storage/settings.rs | 2 +- rust/agama-locale-data/src/timezone_part.rs | 10 +++++----- 22 files changed, 57 insertions(+), 75 deletions(-) diff --git a/rust/agama-cli/src/printers.rs b/rust/agama-cli/src/printers.rs index aa0078fafb..4fe28e9c8a 100644 --- a/rust/agama-cli/src/printers.rs +++ b/rust/agama-cli/src/printers.rs @@ -1,4 +1,3 @@ -use anyhow; use serde::Serialize; use std::fmt::Debug; use std::io::Write; diff --git a/rust/agama-cli/src/profile.rs b/rust/agama-cli/src/profile.rs index 818aaf32db..8d837ece57 100644 --- a/rust/agama-cli/src/profile.rs +++ b/rust/agama-cli/src/profile.rs @@ -39,7 +39,7 @@ fn evaluate(path: String) -> anyhow::Result<()> { let evaluator = ProfileEvaluator {}; evaluator .evaluate(Path::new(&path)) - .context(format!("Could not evaluate the profile"))?; + .context("Could not evaluate the profile".to_string())?; Ok(()) } diff --git a/rust/agama-cli/src/progress.rs b/rust/agama-cli/src/progress.rs index 83dc87e6e1..4694f0da59 100644 --- a/rust/agama-cli/src/progress.rs +++ b/rust/agama-cli/src/progress.rs @@ -29,7 +29,7 @@ impl InstallerProgress { impl ProgressPresenter for InstallerProgress { fn start(&mut self, progress: &Progress) { if !progress.finished { - self.update_main(&progress); + self.update_main(progress); } } @@ -49,7 +49,7 @@ impl ProgressPresenter for InstallerProgress { bar.finish_and_clear(); } } else { - self.update_bar(&progress); + self.update_bar(progress); } } diff --git a/rust/agama-dbus-server/src/locale.rs b/rust/agama-dbus-server/src/locale.rs index 843b6ef5b7..fa25bd5a3e 100644 --- a/rust/agama-dbus-server/src/locale.rs +++ b/rust/agama-dbus-server/src/locale.rs @@ -61,7 +61,7 @@ impl Locale { #[dbus_interface(property)] fn locales(&self) -> Vec { - return self.locales.to_owned(); + self.locales.to_owned() } #[dbus_interface(property)] @@ -112,7 +112,7 @@ impl Locale { #[dbus_interface(property, name = "VConsoleKeyboard")] fn keymap(&self) -> &str { - return &self.keymap.as_str(); + self.keymap.as_str() } #[dbus_interface(property, name = "VConsoleKeyboard")] @@ -120,8 +120,7 @@ impl Locale { let exist = agama_locale_data::get_key_maps() .unwrap() .iter() - .find(|&k| k == keyboard) - .is_some(); + .any(|k| k == keyboard); if !exist { return Err(zbus::fdo::Error::Failed( "Invalid keyboard value".to_string(), @@ -141,7 +140,7 @@ impl Locale { #[dbus_interface(property)] fn timezone(&self) -> &str { - return &self.timezone_id.as_str(); + self.timezone_id.as_str() } #[dbus_interface(property)] diff --git a/rust/agama-dbus-server/src/network/dbus/interfaces.rs b/rust/agama-dbus-server/src/network/dbus/interfaces.rs index d1d36cb602..ada7523b37 100644 --- a/rust/agama-dbus-server/src/network/dbus/interfaces.rs +++ b/rust/agama-dbus-server/src/network/dbus/interfaces.rs @@ -138,7 +138,7 @@ impl Connections { /// * `id`: connection ID. pub async fn get_connection(&self, id: &str) -> zbus::fdo::Result { let objects = self.objects.lock(); - match objects.connection_path(&id) { + match objects.connection_path(id) { Some(path) => Ok(path.into()), None => Err(NetworkStateError::UnknownConnection(id.to_string()).into()), } @@ -308,8 +308,8 @@ impl Ipv4 { .iter() .map(|addr| addr.parse::()) .collect::, AddrParseError>>() - .and_then(|parsed| Ok(ipv4.nameservers = parsed)) - .map_err(|err| NetworkStateError::from(err))?; + .map(|parsed| ipv4.nameservers = parsed) + .map_err(NetworkStateError::from)?; self.update_connection(connection) } @@ -335,7 +335,7 @@ impl Ipv4 { } else { let parsed: Ipv4Addr = gateway .parse() - .map_err(|err| NetworkStateError::from(err))?; + .map_err(NetworkStateError::from)?; ipv4.gateway = Some(parsed); } self.update_connection(connection) diff --git a/rust/agama-dbus-server/src/network/dbus/service.rs b/rust/agama-dbus-server/src/network/dbus/service.rs index 436407390d..ad55f0e3c5 100644 --- a/rust/agama-dbus-server/src/network/dbus/service.rs +++ b/rust/agama-dbus-server/src/network/dbus/service.rs @@ -29,7 +29,7 @@ impl NetworkService { connection .request_name(SERVICE_NAME) .await - .expect(&format!("Could not request name {SERVICE_NAME}")); + .unwrap_or_else(|_| panic!("Could not request name {SERVICE_NAME}")); network.listen().await; }) diff --git a/rust/agama-dbus-server/src/network/dbus/tree.rs b/rust/agama-dbus-server/src/network/dbus/tree.rs index a34adea32e..6230e0a8a5 100644 --- a/rust/agama-dbus-server/src/network/dbus/tree.rs +++ b/rust/agama-dbus-server/src/network/dbus/tree.rs @@ -39,7 +39,7 @@ impl Tree { /// * `connections`: list of connections. pub async fn set_connections( &self, - connections: &mut Vec, + connections: &mut [Connection], ) -> Result<(), ServiceError> { self.remove_connections().await?; self.add_connections(connections).await?; @@ -49,7 +49,7 @@ impl Tree { /// Refreshes the list of devices. /// /// * `devices`: list of devices. - pub async fn set_devices(&mut self, devices: &Vec) -> Result<(), ServiceError> { + pub async fn set_devices(&mut self, devices: &[Device]) -> Result<(), ServiceError> { self.remove_devices().await?; self.add_devices(devices).await?; Ok(()) @@ -58,7 +58,7 @@ impl Tree { /// Adds devices to the D-Bus tree. /// /// * `devices`: list of devices. - pub async fn add_devices(&mut self, devices: &Vec) -> Result<(), ServiceError> { + pub async fn add_devices(&mut self, devices: &[Device]) -> Result<(), ServiceError> { for (i, dev) in devices.iter().enumerate() { let path = format!("{}/{}", DEVICES_PATH, i); let path = ObjectPath::try_from(path.as_str()).unwrap(); @@ -83,7 +83,7 @@ impl Tree { pub async fn add_connection(&self, conn: &mut Connection) -> Result<(), ServiceError> { let mut objects = self.objects.lock(); - let (id, path) = objects.register_connection(&conn); + let (id, path) = objects.register_connection(conn); if id != conn.id() { conn.set_id(&id) } @@ -126,7 +126,7 @@ impl Tree { /// Adds connections to the D-Bus tree. /// /// * `connections`: list of connections. - async fn add_connections(&self, connections: &mut Vec) -> Result<(), ServiceError> { + async fn add_connections(&self, connections: &mut [Connection]) -> Result<(), ServiceError> { for conn in connections.iter_mut() { self.add_connection(conn).await?; } @@ -181,7 +181,7 @@ impl Tree { T: zbus::Interface, { let object_server = self.connection.object_server(); - Ok(object_server.at(path.clone(), iface).await?) + Ok(object_server.at(path, iface).await?) } } diff --git a/rust/agama-dbus-server/src/network/error.rs b/rust/agama-dbus-server/src/network/error.rs index 5eec005909..49a7c3cb5f 100644 --- a/rust/agama-dbus-server/src/network/error.rs +++ b/rust/agama-dbus-server/src/network/error.rs @@ -26,6 +26,6 @@ pub enum NetworkStateError { impl From for zbus::fdo::Error { fn from(value: NetworkStateError) -> zbus::fdo::Error { - zbus::fdo::Error::Failed(format!("Network error: {}", value.to_string())) + zbus::fdo::Error::Failed(format!("Network error: {value}")) } } diff --git a/rust/agama-dbus-server/src/network/model.rs b/rust/agama-dbus-server/src/network/model.rs index d8a2fcb860..c892e4a515 100644 --- a/rust/agama-dbus-server/src/network/model.rs +++ b/rust/agama-dbus-server/src/network/model.rs @@ -56,7 +56,7 @@ impl NetworkState { /// /// It uses the `id` to decide whether the connection already exists. pub fn add_connection(&mut self, conn: Connection) -> Result<(), NetworkStateError> { - if let Some(_) = self.get_connection(conn.id()) { + if self.get_connection(conn.id()).is_some() { return Err(NetworkStateError::ConnectionExists(conn.uuid())); } @@ -206,7 +206,7 @@ pub enum Connection { impl Connection { pub fn new(id: String, device_type: DeviceType) -> Self { let base = BaseConnection { - id: id.to_string(), + id, ..Default::default() }; match device_type { @@ -491,13 +491,11 @@ impl FromStr for IpAddress { type Err = ParseIpAddressError; fn from_str(s: &str) -> Result { - let Some((address, prefix)) = s.split_once("/") else { + let Some((address, prefix)) = s.split_once('/') else { return Err(ParseIpAddressError::MissingPrefix); }; - let address: Ipv4Addr = address - .parse() - .map_err(|e| ParseIpAddressError::InvalidAddr(e))?; + let address: Ipv4Addr = address.parse().map_err(ParseIpAddressError::InvalidAddr)?; let prefix: u32 = prefix .parse() @@ -509,6 +507,6 @@ impl FromStr for IpAddress { impl fmt::Display for IpAddress { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}/{}", self.0.to_string(), self.1) + write!(f, "{}/{}", self.0, self.1) } } diff --git a/rust/agama-dbus-server/src/network/nm/adapter.rs b/rust/agama-dbus-server/src/network/nm/adapter.rs index 261b547c54..23dda0a03a 100644 --- a/rust/agama-dbus-server/src/network/nm/adapter.rs +++ b/rust/agama-dbus-server/src/network/nm/adapter.rs @@ -22,10 +22,7 @@ impl<'a> NetworkManagerAdapter<'a> { /// /// * `conn`: connection fn is_writable(conn: &Connection) -> bool { - match conn { - Connection::Loopback(_) => false, - _ => true, - } + matches!(conn, Connection::Loopback(_)) } } @@ -51,10 +48,8 @@ impl<'a> Adapter for NetworkManagerAdapter<'a> { if let Err(e) = self.client.remove_connection(conn.uuid()).await { log::error!("Could not remove the connection {}: {}", conn.uuid(), e); } - } else { - if let Err(e) = self.client.add_or_update_connection(conn).await { - log::error!("Could not add/update the connection {}: {}", conn.uuid(), e); - } + } else if let Err(e) = self.client.add_or_update_connection(conn).await { + log::error!("Could not add/update the connection {}: {}", conn.uuid(), e); } } }); diff --git a/rust/agama-dbus-server/src/network/nm/client.rs b/rust/agama-dbus-server/src/network/nm/client.rs index dbcf7c47a4..9c859b586d 100644 --- a/rust/agama-dbus-server/src/network/nm/client.rs +++ b/rust/agama-dbus-server/src/network/nm/client.rs @@ -79,7 +79,7 @@ impl<'a> NetworkManagerClient<'a> { let settings = proxy.get_settings().await?; // TODO: log an error if a connection is not found if let Some(connection) = connection_from_dbus(settings) { - connections.push(connection.into()); + connections.push(connection); } } Ok(connections) diff --git a/rust/agama-dbus-server/src/network/nm/dbus.rs b/rust/agama-dbus-server/src/network/nm/dbus.rs index a52c3ee0c7..7511b44399 100644 --- a/rust/agama-dbus-server/src/network/nm/dbus.rs +++ b/rust/agama-dbus-server/src/network/nm/dbus.rs @@ -83,7 +83,7 @@ pub fn merge_dbus_connections<'a>( inner.insert(inner_key, value.clone()); } } - merged.insert(key.as_str(), inner.into()); + merged.insert(key.as_str(), inner); } cleanup_dbus_connection(&mut merged); merged @@ -95,7 +95,7 @@ pub fn merge_dbus_connections<'a>( /// replaced with "address-data". However, if "addresses" is present, it takes precedence. /// /// * `conn`: connection represented as a NestedHash. -fn cleanup_dbus_connection<'a>(conn: &'a mut NestedHash) { +fn cleanup_dbus_connection(conn: &mut NestedHash) { if let Some(ipv4) = conn.get_mut("ipv4") { ipv4.remove("addresses"); ipv4.remove("dns"); @@ -123,7 +123,7 @@ fn ipv4_to_dbus(ipv4: &Ipv4Config) -> HashMap<&str, zvariant::Value> { let dns_data: Value = ipv4 .nameservers .iter() - .map(|ns| ns.to_string().into()) + .map(|ns| ns.to_string()) .collect::>() .into(); @@ -263,7 +263,7 @@ mod test { let address_data = vec![HashMap::from([ ("address".to_string(), Value::new("192.168.0.10")), - ("prefix".to_string(), Value::new(24 as u32)), + ("prefix".to_string(), Value::new(24_u32)), ])]; let ipv4_section = HashMap::from([ diff --git a/rust/agama-dbus-server/src/network/nm/model.rs b/rust/agama-dbus-server/src/network/nm/model.rs index cfffdf0cb5..33769252e1 100644 --- a/rust/agama-dbus-server/src/network/nm/model.rs +++ b/rust/agama-dbus-server/src/network/nm/model.rs @@ -30,7 +30,7 @@ impl From<&str> for NmWirelessMode { impl NmWirelessMode { pub fn as_str(&self) -> &str { - &self.0.as_str() + self.0.as_str() } } @@ -59,7 +59,7 @@ impl fmt::Display for NmWirelessMode { /// As we are using the number just to filter wireless devices, using the newtype /// pattern around an u32 is enough. For proper support, we might replace this /// struct with an enum. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Default, Clone, Copy)] pub struct NmDeviceType(pub u32); impl From for u32 { @@ -74,12 +74,6 @@ impl fmt::Display for NmDeviceType { } } -impl Default for NmDeviceType { - fn default() -> Self { - NmDeviceType(0) - } -} - impl TryFrom for DeviceType { type Error = NmError; @@ -131,7 +125,7 @@ impl TryFrom for SecurityProtocol { impl NmKeyManagement { pub fn as_str(&self) -> &str { - &self.0.as_str() + self.0.as_str() } } @@ -152,7 +146,7 @@ impl Default for NmMethod { impl NmMethod { pub fn as_str(&self) -> &str { - &self.0.as_str() + self.0.as_str() } } diff --git a/rust/agama-dbus-server/src/questions.rs b/rust/agama-dbus-server/src/questions.rs index 5df6f7af7f..e523533783 100644 --- a/rust/agama-dbus-server/src/questions.rs +++ b/rust/agama-dbus-server/src/questions.rs @@ -137,7 +137,7 @@ impl LuksQuestion { } #[dbus_interface(property)] - pub fn set_password(&mut self, value: &str) -> () { + pub fn set_password(&mut self, value: &str) { self.password = value.to_string(); } @@ -227,7 +227,7 @@ impl Questions { /// Removes question at given object path async fn delete(&mut self, question: ObjectPath<'_>) -> Result<(), Error> { // TODO: error checking - let id: u32 = question.rsplit("/").next().unwrap().parse().unwrap(); + let id: u32 = question.rsplit('/').next().unwrap().parse().unwrap(); let qtype = self.questions.get(&id).unwrap(); match qtype { QuestionType::Generic => { diff --git a/rust/agama-lib/src/network/client.rs b/rust/agama-lib/src/network/client.rs index 7f788900a3..a849c1b164 100644 --- a/rust/agama-lib/src/network/client.rs +++ b/rust/agama-lib/src/network/client.rs @@ -107,9 +107,9 @@ impl<'a> NetworkClient<'a> { ) -> Result<(), ServiceError> { let path = match self.connections_proxy.get_connection(&conn.id).await { Ok(path) => path, - Err(_) => self.add_connection(&conn).await?, + Err(_) => self.add_connection(conn).await?, }; - self.update_connection(&path, &conn).await?; + self.update_connection(&path, conn).await?; Ok(()) } @@ -150,11 +150,11 @@ impl<'a> NetworkClient<'a> { let nameservers: Vec<_> = conn.nameservers.iter().map(String::as_ref).collect(); proxy.set_nameservers(nameservers.as_slice()).await?; - let gateway = conn.gateway.as_ref().map(|g| g.as_str()).unwrap_or(""); + let gateway = conn.gateway.as_deref().unwrap_or(""); proxy.set_gateway(gateway).await?; if let Some(ref wireless) = conn.wireless { - self.update_wireless_settings(&path, wireless).await?; + self.update_wireless_settings(path, wireless).await?; } Ok(()) } diff --git a/rust/agama-lib/src/network/store.rs b/rust/agama-lib/src/network/store.rs index 73b5146c5e..b4711274a7 100644 --- a/rust/agama-lib/src/network/store.rs +++ b/rust/agama-lib/src/network/store.rs @@ -18,15 +18,12 @@ impl<'a> NetworkStore<'a> { pub async fn load(&self) -> Result { let connections = self.network_client.connections().await?; - Ok(NetworkSettings { - connections, - ..Default::default() - }) + Ok(NetworkSettings { connections }) } pub async fn store(&self, settings: &NetworkSettings) -> Result<(), ServiceError> { for conn in &settings.connections { - self.network_client.add_or_update_connection(&conn).await?; + self.network_client.add_or_update_connection(conn).await?; } self.network_client.apply().await?; diff --git a/rust/agama-lib/src/network/types.rs b/rust/agama-lib/src/network/types.rs index 5c3ea6cf2f..5aa56c5145 100644 --- a/rust/agama-lib/src/network/types.rs +++ b/rust/agama-lib/src/network/types.rs @@ -20,7 +20,7 @@ impl fmt::Display for SSID { impl From for Vec { fn from(value: SSID) -> Self { - value.0.clone() + value.0 } } @@ -50,7 +50,7 @@ impl TryFrom for DeviceType { impl From for zbus::fdo::Error { fn from(value: InvalidDeviceType) -> zbus::fdo::Error { - zbus::fdo::Error::Failed(format!("Network error: {}", value.to_string())) + zbus::fdo::Error::Failed(format!("Network error: {value}")) } } diff --git a/rust/agama-lib/src/profile.rs b/rust/agama-lib/src/profile.rs index 6405482654..dab1326583 100644 --- a/rust/agama-lib/src/profile.rs +++ b/rust/agama-lib/src/profile.rs @@ -136,9 +136,9 @@ impl ProfileEvaluator { .output() .context("Failed to run lshw")?; let mut file = fs::File::create(path)?; - file.write(b"{ \"disks\":\n")?; + file.write_all(b"{ \"disks\":\n")?; file.write_all(&result.stdout)?; - file.write(b"\n}")?; + file.write_all(b"\n}")?; Ok(()) } } diff --git a/rust/agama-lib/src/settings.rs b/rust/agama-lib/src/settings.rs index 13ad97e3c9..29af38a533 100644 --- a/rust/agama-lib/src/settings.rs +++ b/rust/agama-lib/src/settings.rs @@ -166,11 +166,11 @@ mod tests { fn test_try_from_bool() { let value = SettingValue("true".to_string()); let value: bool = value.try_into().unwrap(); - assert_eq!(value, true); + assert!(value); let value = SettingValue("false".to_string()); let value: bool = value.try_into().unwrap(); - assert_eq!(value, false); + assert!(!value); } #[test] diff --git a/rust/agama-lib/src/software/store.rs b/rust/agama-lib/src/software/store.rs index 996ee05ebd..ad1a76d562 100644 --- a/rust/agama-lib/src/software/store.rs +++ b/rust/agama-lib/src/software/store.rs @@ -28,7 +28,7 @@ impl<'a> SoftwareStore<'a> { if let Some(product) = &settings.product { let products = self.software_client.products().await?; let ids: Vec = products.into_iter().map(|p| p.id).collect(); - if ids.contains(&product) { + if ids.contains(product) { self.software_client.select_product(product).await?; } else { return Err(ServiceError::UnknownProduct(product.clone(), ids)); diff --git a/rust/agama-lib/src/storage/settings.rs b/rust/agama-lib/src/storage/settings.rs index 74afd59384..cdba404196 100644 --- a/rust/agama-lib/src/storage/settings.rs +++ b/rust/agama-lib/src/storage/settings.rs @@ -39,7 +39,7 @@ impl TryFrom for Device { Some(name) => Ok(Device { name: name.clone().try_into()?, }), - _ => return Err(SettingsError::MissingKey("name".to_string())), + _ => Err(SettingsError::MissingKey("name".to_string())), } } } diff --git a/rust/agama-locale-data/src/timezone_part.rs b/rust/agama-locale-data/src/timezone_part.rs index 256fd3000c..c1390c3815 100644 --- a/rust/agama-locale-data/src/timezone_part.rs +++ b/rust/agama-locale-data/src/timezone_part.rs @@ -29,7 +29,7 @@ impl TimezoneIdParts { /// let result = vec!["Evropa/Praha".to_string(), "Evropa/BerlĂ­n".to_string()]; /// assert_eq!(parts.localize_timezones("cs", &timezones), result); /// ``` - pub fn localize_timezones(&self, language: &str, timezones: &Vec) -> Vec { + pub fn localize_timezones(&self, language: &str, timezones: &[String]) -> Vec { let mapping = self.construct_mapping(language); timezones .iter() @@ -42,22 +42,22 @@ impl TimezoneIdParts { self.timezone_part .iter() .map(|part| (part.id.clone(), part.names.name_for(language))) - .for_each(|(time_id, names)| -> () { + .for_each(|(time_id, names)| { // skip missing translations if let Some(trans) = names { res.insert(time_id, trans); } }); - return res; + res } fn translate_timezone(&self, mapping: &HashMap, timezone: &str) -> String { timezone - .split("/") + .split('/') .map(|tzp| { mapping .get(&tzp.to_string()) - .expect(format!("Unknown timezone part {tzp}").as_str()) + .unwrap_or_else(|| panic!("Unknown timezone part {tzp}")) .to_owned() }) .collect::>() From e32d3c0129e78618534c9aefa4a6c107477f4920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Thu, 13 Jul 2023 14:01:08 +0100 Subject: [PATCH 2/2] Fix a formatting issue --- rust/agama-dbus-server/src/network/dbus/interfaces.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rust/agama-dbus-server/src/network/dbus/interfaces.rs b/rust/agama-dbus-server/src/network/dbus/interfaces.rs index ada7523b37..e85f1d188e 100644 --- a/rust/agama-dbus-server/src/network/dbus/interfaces.rs +++ b/rust/agama-dbus-server/src/network/dbus/interfaces.rs @@ -333,9 +333,7 @@ impl Ipv4 { if gateway.is_empty() { ipv4.gateway = None; } else { - let parsed: Ipv4Addr = gateway - .parse() - .map_err(NetworkStateError::from)?; + let parsed: Ipv4Addr = gateway.parse().map_err(NetworkStateError::from)?; ipv4.gateway = Some(parsed); } self.update_connection(connection)