Skip to content

Commit 7167a06

Browse files
committed
Add Ipv4Addr BROADCAST assoc const
1 parent e9a96c0 commit 7167a06

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: src/libstd/net/ip.rs

+18
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,22 @@ impl Ipv4Addr {
385385
issue = "44582")]
386386
pub const UNSPECIFIED: Self = Ipv4Addr::new(0, 0, 0, 0);
387387

388+
/// An IPv4 address representing the broadcast address: 255.255.255.255
389+
///
390+
/// # Examples
391+
///
392+
/// ```
393+
/// #![feature(ip_constructors)]
394+
/// use std::net::Ipv4Addr;
395+
///
396+
/// let addr = Ipv4Addr::BROADCAST;
397+
/// assert_eq!(addr, Ipv4Addr::new(255, 255, 255, 255));
398+
/// ```
399+
#[unstable(feature = "ip_constructors",
400+
reason = "requires greater scrutiny before stabilization",
401+
issue = "44582")]
402+
pub const BROADCAST: Self = Ipv4Addr::new(255, 255, 255, 255);
403+
388404
/// Returns the four eight-bit integers that make up this address.
389405
///
390406
/// # Examples
@@ -1850,6 +1866,8 @@ mod tests {
18501866
assert!(Ipv4Addr::LOCALHOST.is_loopback());
18511867
assert_eq!(Ipv4Addr::UNSPECIFIED, Ipv4Addr::new(0, 0, 0, 0));
18521868
assert!(Ipv4Addr::UNSPECIFIED.is_unspecified());
1869+
assert_eq!(Ipv4Addr::BROADCAST, Ipv4Addr::new(255, 255, 255, 255));
1870+
assert!(Ipv4Addr::BROADCAST.is_broadcast());
18531871
}
18541872

18551873
#[test]

0 commit comments

Comments
 (0)