Skip to content

Commit

Permalink
ldp, ospf: simplify the get_router_id() methods
Browse files Browse the repository at this point in the history
Replace conditional checks in the `get_router_id` methods with the
more concise `Option::or` combinator.

Signed-off-by: Renato Westphal <[email protected]>
  • Loading branch information
rwestphal committed Jan 26, 2024
1 parent 21bd8b4 commit f684b06
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
8 changes: 1 addition & 7 deletions holo-ldp/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,7 @@ impl Instance {
}

fn get_router_id(&self) -> Option<Ipv4Addr> {
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(
Expand Down
8 changes: 1 addition & 7 deletions holo-ospf/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,7 @@ where
}

pub(crate) fn get_router_id(&self) -> Option<Ipv4Addr> {
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.
Expand Down

0 comments on commit f684b06

Please sign in to comment.