Skip to content

Commit 020ce1f

Browse files
committed
ip link: make apply_bridge synchronous and fix style
apply_bridge contains no .await calls, so the async annotation is unnecessary. Make it a regular fn and drop the .await at the call site in add.rs. Also replace the `if let Some(ref addr) = self.field` pattern with the more idiomatic Rust 2024 `if let Some(addr) = &self.field` style already used elsewhere in the file. Signed-off-by: Gris Ge <cnfourt@gmail.com>
1 parent 8cb3e4d commit 020ce1f

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

src/ip/link/add.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ impl LinkAddCommand {
5555
InfoKind::Bond => {
5656
base_conf.apply(base_conf.apply_bond(&handle).await?)?
5757
}
58-
InfoKind::Bridge => {
59-
base_conf.apply(base_conf.apply_bridge().await?)?
60-
}
58+
InfoKind::Bridge => base_conf.apply(base_conf.apply_bridge()?)?,
6159
t => {
6260
return Err(CliError::from(format!(
6361
"Unsupported device type: {t}"

src/ip/link/ifaces/bridge.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ impl std::fmt::Display for CliLinkInfoDataBridge {
426426
write!(f, " mcast_router {}", self.mcast_router)?;
427427
write!(f, " mcast_query_use_ifaddr {}", self.mcast_query_use_ifaddr)?;
428428
write!(f, " mcast_querier {}", self.mcast_querier)?;
429-
if let Some(ref addr) = self.mcast_querier_ipv4_addr {
429+
if let Some(addr) = &self.mcast_querier_ipv4_addr {
430430
write!(f, " mcast_querier_ipv4_addr {}", addr)?;
431431
}
432-
if let Some(ref addr) = self.mcast_querier_ipv6_addr {
432+
if let Some(addr) = &self.mcast_querier_ipv6_addr {
433433
write!(f, " mcast_querier_ipv6_addr {}", addr)?;
434434
}
435435
write!(f, " mcast_hash_elasticity {}", self.mcast_hash_elasticity)?;
@@ -732,7 +732,7 @@ fn format_bridge_timer(v: u64) -> String {
732732
}
733733

734734
impl LinkBaseConf {
735-
pub(crate) async fn apply_bridge(
735+
pub(crate) fn apply_bridge(
736736
&self,
737737
) -> Result<LinkMessageBuilder<LinkBridge>, CliError> {
738738
let mut builder = LinkBridge::new(&self.name);

0 commit comments

Comments
 (0)