@@ -559,37 +559,51 @@ impl hash::Hash for SocketAddrV6 {
559
559
}
560
560
561
561
/// A trait for objects which can be converted or resolved to one or more
562
- /// `SocketAddr` values.
562
+ /// [ `SocketAddr`] values.
563
563
///
564
564
/// This trait is used for generic address resolution when constructing network
565
565
/// objects. By default it is implemented for the following types:
566
566
///
567
- /// * `SocketAddr`, `SocketAddrV4`, `SocketAddrV6` - `to_socket_addrs` is
568
- /// identity function.
567
+ /// * [`SocketAddr`]: [`to_socket_addrs`] is the identity function.
569
568
///
570
- /// * `(IpvNAddr, u16)` - `to_socket_addrs` constructs `SocketAddr` trivially.
569
+ /// * [`SocketAddrV4`], [`SocketAddrV6`], `(`[`IpAddr`]`, `[`u16`]`)`,
570
+ /// `(`[`Ipv4Addr`]`, `[`u16`]`)`, `(`[`Ipv6Addr`]`, `[`u16`]`)`:
571
+ /// [`to_socket_addrs`] constructs a [`SocketAddr`] trivially.
571
572
///
572
- /// * `(&str, u16)` - the string should be either a string representation of an
573
- /// IP address expected by `FromStr` implementation for `IpvNAddr` or a host
573
+ /// * `(`[` &str`]`, `[` u16`]`)`: the string should be either a string representation
574
+ /// of an [`IpAddr`] address as expected by [ `FromStr`] implementation or a host
574
575
/// name.
575
576
///
576
- /// * `&str` - the string should be either a string representation of a
577
- /// `SocketAddr` as expected by its `FromStr` implementation or a string like
578
- /// `<host_name>:<port>` pair where `<port>` is a `u16` value.
577
+ /// * [ `&str`]: the string should be either a string representation of a
578
+ /// [ `SocketAddr`] as expected by its [ `FromStr`] implementation or a string like
579
+ /// `<host_name>:<port>` pair where `<port>` is a [ `u16`] value.
579
580
///
580
- /// This trait allows constructing network objects like `TcpStream` or
581
- /// `UdpSocket` easily with values of various types for the bind/connection
581
+ /// This trait allows constructing network objects like [ `TcpStream`] or
582
+ /// [ `UdpSocket`] easily with values of various types for the bind/connection
582
583
/// address. It is needed because sometimes one type is more appropriate than
583
584
/// the other: for simple uses a string like `"localhost:12345"` is much nicer
584
- /// than manual construction of the corresponding `SocketAddr`, but sometimes
585
- /// `SocketAddr` value is *the* main source of the address, and converting it to
585
+ /// than manual construction of the corresponding [ `SocketAddr`] , but sometimes
586
+ /// [ `SocketAddr`] value is *the* main source of the address, and converting it to
586
587
/// some other type (e.g. a string) just for it to be converted back to
587
- /// `SocketAddr` in constructor methods is pointless.
588
+ /// [ `SocketAddr`] in constructor methods is pointless.
588
589
///
589
590
/// Addresses returned by the operating system that are not IP addresses are
590
591
/// silently ignored.
591
592
///
592
- /// Some examples:
593
+ /// [`FromStr`]: ../../std/str/trait.FromStr.html
594
+ /// [`IpAddr`]: ../../std/net/enum.IpAddr.html
595
+ /// [`Ipv4Addr`]: ../../std/net/struct.Ipv4Addr.html
596
+ /// [`Ipv6Addr`]: ../../std/net/struct.Ipv6Addr.html
597
+ /// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
598
+ /// [`SocketAddrV4`]: ../../std/net/struct.SocketAddrV4.html
599
+ /// [`SocketAddrV6`]: ../../std/net/struct.SocketAddrV6.html
600
+ /// [`&str`]: ../../std/primitive.str.html
601
+ /// [`TcpStream`]: ../../std/net/struct.TcpStream.html
602
+ /// [`to_socket_addrs`]: #tymethod.to_socket_addrs
603
+ /// [`UdpSocket`]: ../../std/net/struct.UdpSocket.html
604
+ /// [`u16`]: ../../std/primitive.u16.html
605
+ ///
606
+ /// # Examples
593
607
///
594
608
/// ```no_run
595
609
/// use std::net::{SocketAddrV4, TcpStream, UdpSocket, TcpListener, Ipv4Addr};
@@ -622,17 +636,21 @@ pub trait ToSocketAddrs {
622
636
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
623
637
type Iter : Iterator < Item =SocketAddr > ;
624
638
625
- /// Converts this object to an iterator of resolved `SocketAddr`s.
639
+ /// Converts this object to an iterator of resolved [ `SocketAddr`] s.
626
640
///
627
641
/// The returned iterator may not actually yield any values depending on the
628
642
/// outcome of any resolution performed.
629
643
///
630
644
/// Note that this function may block the current thread while resolution is
631
645
/// performed.
632
646
///
647
+ /// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
648
+ ///
633
649
/// # Errors
634
650
///
635
- /// Any errors encountered during resolution will be returned as an `Err`.
651
+ /// Any errors encountered during resolution will be returned as an [`Err`].
652
+ ///
653
+ /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
636
654
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
637
655
fn to_socket_addrs ( & self ) -> io:: Result < Self :: Iter > ;
638
656
}
0 commit comments