refactor: No need to store domain string in enum

pull/1/head
sgoudham 2 years ago
parent de446012c1
commit ac48831a86
Signed by: hammy
GPG Key ID: 44E818FD5457EEA4

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

Loading…
Cancel
Save