about summary refs log tree commit diff
path: root/src/libstd/io/net/addrinfo.rs
diff options
context:
space:
mode:
authorSean McArthur <sean.monstar@gmail.com>2014-12-20 00:09:35 -0800
committerSean McArthur <sean.monstar@gmail.com>2015-01-06 14:49:42 -0800
commit44440e5c18a1dbcc9685866ffffe00c508929079 (patch)
treeb66c50cd1e471dc0e37b8a0db2cf7f8f28fbac5f /src/libstd/io/net/addrinfo.rs
parent8efd9901b628d687d11a4d0ccc153553b38ada49 (diff)
downloadrust-44440e5c18a1dbcc9685866ffffe00c508929079.tar.gz
rust-44440e5c18a1dbcc9685866ffffe00c508929079.zip
core: split into fmt::Show and fmt::String
fmt::Show is for debugging, and can and should be implemented for
all public types. This trait is used with `{:?}` syntax. There still
exists #[derive(Show)].

fmt::String is for types that faithfully be represented as a String.
Because of this, there is no way to derive fmt::String, all
implementations must be purposeful. It is used by the default format
syntax, `{}`.

This will break most instances of `{}`, since that now requires the type
to impl fmt::String. In most cases, replacing `{}` with `{:?}` is the
correct fix. Types that were being printed specifically for users should
receive a fmt::String implementation to fix this.

Part of #20013

[breaking-change]
Diffstat (limited to 'src/libstd/io/net/addrinfo.rs')
-rw-r--r--src/libstd/io/net/addrinfo.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs
index 24d45dcd652..7825a4e16e1 100644
--- a/src/libstd/io/net/addrinfo.rs
+++ b/src/libstd/io/net/addrinfo.rs
@@ -29,7 +29,7 @@ use sys;
 use vec::Vec;
 
 /// Hints to the types of sockets that are desired when looking up hosts
-#[derive(Copy)]
+#[derive(Copy, Show)]
 pub enum SocketType {
     Stream, Datagram, Raw
 }
@@ -38,7 +38,7 @@ pub enum SocketType {
 /// to manipulate how a query is performed.
 ///
 /// The meaning of each of these flags can be found with `man -s 3 getaddrinfo`
-#[derive(Copy)]
+#[derive(Copy, Show)]
 pub enum Flag {
     AddrConfig,
     All,
@@ -51,7 +51,7 @@ pub enum Flag {
 
 /// A transport protocol associated with either a hint or a return value of
 /// `lookup`
-#[derive(Copy)]
+#[derive(Copy, Show)]
 pub enum Protocol {
     TCP, UDP
 }
@@ -61,7 +61,7 @@ pub enum Protocol {
 ///
 /// For details on these fields, see their corresponding definitions via
 /// `man -s 3 getaddrinfo`
-#[derive(Copy)]
+#[derive(Copy, Show)]
 pub struct Hint {
     pub family: uint,
     pub socktype: Option<SocketType>,
@@ -69,7 +69,7 @@ pub struct Hint {
     pub flags: uint,
 }
 
-#[derive(Copy)]
+#[derive(Copy, Show)]
 pub struct Info {
     pub address: SocketAddr,
     pub family: uint,