]> git.lizzy.rs Git - rust.git/commitdiff
Add doc examples for std::net::IpAddr construction.
authorCorey Farwell <coreyf@rwell.org>
Wed, 14 Sep 2016 02:07:38 +0000 (22:07 -0400)
committerCorey Farwell <coreyf@rwell.org>
Wed, 14 Sep 2016 02:07:38 +0000 (22:07 -0400)
src/libstd/net/ip.rs

index c6a7a77e68a6b369c4cfd06f33e1cb67d7a95d1a..05ef559422f33187707e1894c56eef67800945cf 100644 (file)
 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 {