Skip to content

Commit

Permalink
Add documentation to help people find Ipv4Addr::UNSPECIFIED
Browse files Browse the repository at this point in the history
People looking for `INADDR_ANY` don't always find
`Ipv4Addr::UNSPECIFIED`; add some documentation and an alias to help.
  • Loading branch information
joshtriplett committed Apr 16, 2021
1 parent 0cc00c4 commit 9aa4d06
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/std/src/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ impl Ipv4Addr {

/// An IPv4 address representing an unspecified address: 0.0.0.0
///
/// This corresponds to the constant `INADDR_ANY` in other languages.
///
/// # Examples
///
/// ```
Expand All @@ -342,6 +344,7 @@ impl Ipv4Addr {
/// let addr = Ipv4Addr::UNSPECIFIED;
/// assert_eq!(addr, Ipv4Addr::new(0, 0, 0, 0));
/// ```
#[doc(alias = "INADDR_ANY")]
#[stable(feature = "ip_constructors", since = "1.30.0")]
pub const UNSPECIFIED: Self = Ipv4Addr::new(0, 0, 0, 0);

Expand Down

0 comments on commit 9aa4d06

Please sign in to comment.