Macro ip_addr
macro_rules! ip_addr {
(v4, $s:expr) => { ... };
(v6, $s:expr) => { ... };
($s:expr) => { ... };
}
Available on crate feature
dep_const_str
only.Expand description
Converts a string slice to an IP address.
This macro is const-fn compatible.
§Examples
use core::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use const_str::ip_addr;
const LOCALHOST_V4: Ipv4Addr = ip_addr!(v4, "127.0.0.1");
const LOCALHOST_V6: Ipv6Addr = ip_addr!(v6, "::1");
const LOCALHOSTS: [IpAddr;2] = [ip_addr!("127.0.0.1"), ip_addr!("::1")];