Skip to content

Commit

Permalink
Add Ipv4Addr BROADCAST assoc const
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Aug 8, 2018
1 parent e9a96c0 commit 7167a06
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/libstd/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,22 @@ impl Ipv4Addr {
issue = "44582")]
pub const UNSPECIFIED: Self = Ipv4Addr::new(0, 0, 0, 0);

/// An IPv4 address representing the broadcast address: 255.255.255.255
///
/// # Examples
///
/// ```
/// #![feature(ip_constructors)]
/// use std::net::Ipv4Addr;
///
/// let addr = Ipv4Addr::BROADCAST;
/// assert_eq!(addr, Ipv4Addr::new(255, 255, 255, 255));
/// ```
#[unstable(feature = "ip_constructors",
reason = "requires greater scrutiny before stabilization",
issue = "44582")]
pub const BROADCAST: Self = Ipv4Addr::new(255, 255, 255, 255);

/// Returns the four eight-bit integers that make up this address.
///
/// # Examples
Expand Down Expand Up @@ -1850,6 +1866,8 @@ mod tests {
assert!(Ipv4Addr::LOCALHOST.is_loopback());
assert_eq!(Ipv4Addr::UNSPECIFIED, Ipv4Addr::new(0, 0, 0, 0));
assert!(Ipv4Addr::UNSPECIFIED.is_unspecified());
assert_eq!(Ipv4Addr::BROADCAST, Ipv4Addr::new(255, 255, 255, 255));
assert!(Ipv4Addr::BROADCAST.is_broadcast());
}

#[test]
Expand Down

0 comments on commit 7167a06

Please sign in to comment.