Skip to content

Add doc examples for std::net::IpAddr construction. #36467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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