Skip to content

Commit 4ac32c6

Browse files
authored
stun: simplify XorMappedAddress Display implementation (#725)
Signed-off-by: Xiaobo Liu <[email protected]>
1 parent 536ea96 commit 4ac32c6

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

stun/src/xoraddr.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,9 @@ impl Default for XorMappedAddress {
8181

8282
impl fmt::Display for XorMappedAddress {
8383
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
84-
let family = match self.ip {
85-
IpAddr::V4(_) => FAMILY_IPV4,
86-
IpAddr::V6(_) => FAMILY_IPV6,
87-
};
88-
if family == FAMILY_IPV4 {
89-
write!(f, "{}:{}", self.ip, self.port)
90-
} else {
91-
write!(f, "[{}]:{}", self.ip, self.port)
84+
match self.ip {
85+
IpAddr::V4(_) => write!(f, "{}:{}", self.ip, self.port),
86+
IpAddr::V6(_) => write!(f, "[{}]:{}", self.ip, self.port),
9287
}
9388
}
9489
}

0 commit comments

Comments
 (0)