Skip to content

Commit

Permalink
refactor: No need to store domain string in enum
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoudham committed Jun 13, 2022
1 parent de44601 commit ac48831
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/git.rs
Expand Up @@ -15,8 +15,8 @@ pub(crate) enum Git<'a> {

#[derive(Debug)]
pub(crate) enum Domain {
Github(String),
BitBucket(String),
GitHub,
BitBucket,
}

#[derive(Debug)]
Expand Down Expand Up @@ -107,9 +107,9 @@ impl Url {
impl Domain {
pub(crate) fn from_str(s: &str) -> Self {
if s == "bitbucket.org" {
Domain::BitBucket(s.to_owned())
Domain::BitBucket
} else {
Domain::Github(s.to_owned())
Domain::GitHub
}
}
}
Expand All @@ -123,7 +123,8 @@ impl PartialEq for Domain {
impl fmt::Display for Domain {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Domain::Github(str) | Domain::BitBucket(str) => write!(f, "{}", str),
Domain::GitHub => write!(f, "github.com"),
Domain::BitBucket => write!(f, "bitbucket.org"),
}
}
}

0 comments on commit ac48831

Please sign in to comment.