From f684b062a4dff6c668a24875f85b9c1f832b1148 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Thu, 25 Jan 2024 23:16:31 -0300 Subject: [PATCH] ldp, ospf: simplify the `get_router_id()` methods Replace conditional checks in the `get_router_id` methods with the more concise `Option::or` combinator. Signed-off-by: Renato Westphal --- holo-ldp/src/instance.rs | 8 +------- holo-ospf/src/instance.rs | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/holo-ldp/src/instance.rs b/holo-ldp/src/instance.rs index 42796978..870cdb03 100644 --- a/holo-ldp/src/instance.rs +++ b/holo-ldp/src/instance.rs @@ -241,13 +241,7 @@ impl Instance { } fn get_router_id(&self) -> Option { - if self.config.router_id.is_some() { - self.config.router_id - } else if self.system.router_id.is_some() { - self.system.router_id - } else { - None - } + self.config.router_id.or(self.system.router_id) } pub(crate) fn as_up( diff --git a/holo-ospf/src/instance.rs b/holo-ospf/src/instance.rs index 634d66ce..c715fb2b 100644 --- a/holo-ospf/src/instance.rs +++ b/holo-ospf/src/instance.rs @@ -340,13 +340,7 @@ where } pub(crate) fn get_router_id(&self) -> Option { - if self.config.router_id.is_some() { - self.config.router_id - } else if self.system.router_id.is_some() { - self.system.router_id - } else { - None - } + self.config.router_id.or(self.system.router_id) } // Retrieves the boot count of the instance from non-volatile memory.