Skip to content

Commit

Permalink
Refactor Name fns
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Jul 18, 2024
1 parent 03d29ac commit 392e1f6
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions cmd/soroban-cli/src/commands/network/container/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,19 @@ impl Name {
}

pub fn get_internal_container_name(&self) -> String {
self.0.as_ref().map_or_else(
|| {
format!(
"stellar-{}",
self.1
.expect("Container name and/or network are required.")
.to_string()
)
},
|name| format!("stellar-{}", name.to_string()),
)
match (&self.0, &self.1) {
(Some(name), _) => format!("stellar-{}", name),
(None, Some(network)) => format!("stellar-{}", network),
(None, None) => panic!("Container name and/or network are required."),
}
}

pub fn get_external_container_name(&self) -> String {
self.0.as_ref().map_or_else(
|| {
self.1
.expect("Container name and/or network are required.")
.to_string()
},
std::string::ToString::to_string,
)
match (&self.0, &self.1) {
(Some(name), _) => name.to_string(),
(None, Some(network)) => network.to_string(),
(None, None) => panic!("Container name and/or network are required."),
}
}
}

Expand Down

0 comments on commit 392e1f6

Please sign in to comment.