Skip to content

Commit

Permalink
Rollup merge of #36467 - frewsxcv:ipaddr, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Add doc examples for std::net::IpAddr construction.

None
  • Loading branch information
GuillaumeGomez authored Sep 14, 2016
2 parents a89690e + fae439b commit e368cdd
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 @@ -22,6 +22,24 @@ use sys::net::netc as c;
use sys_common::{AsInner, FromInner};

/// An IP address, either an IPv4 or IPv6 address.
///
/// # Examples
///
/// Constructing an IPv4 address:
///
/// ```
/// use std::net::{IpAddr, Ipv4Addr};
///
/// IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
/// ```
///
/// Constructing an IPv6 address:
///
/// ```
/// use std::net::{IpAddr, Ipv6Addr};
///
/// IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
/// ```
#[stable(feature = "ip_addr", since = "1.7.0")]
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, PartialOrd, Ord)]
pub enum IpAddr {
Expand Down

0 comments on commit e368cdd

Please sign in to comment.