relay_event_normalization::span::description

Function concatenate_host_and_port

source
pub fn concatenate_host_and_port(
    host: Option<&str>,
    port: Option<u16>,
) -> Cow<'_, str>
Expand description

Concatenate an optional host and an optional port.

Returns either a host + port combination, or the host. Never returns just the port.

ยงExamples

use relay_event_normalization::span::description::concatenate_host_and_port;

assert_eq!(concatenate_host_and_port(None, None), "");
assert_eq!(concatenate_host_and_port(Some("my.domain.com"), None), "my.domain.com");
assert_eq!(concatenate_host_and_port(Some("my.domain.com"), Some(1919)), "my.domain.com:1919");