summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-02-24 04:11:53 -0800
committerbors <bors@rust-lang.org>2014-02-24 04:11:53 -0800
commit672097753a217d4990129cbdfab16ef8c9b08b21 (patch)
treecf206fc1ba6465032dac4fdce670860538da0140 /src/libstd
parenta5342d5970d57dd0cc4805ba0f5385d7f3859c94 (diff)
parent8761f79485f11ef03eb6cb569ccb9f4c73e68f11 (diff)
downloadrust-672097753a217d4990129cbdfab16ef8c9b08b21.tar.gz
rust-672097753a217d4990129cbdfab16ef8c9b08b21.zip
auto merge of #12412 : alexcrichton/rust/deriving-show, r=huonw
This commit removes deriving(ToStr) in favor of deriving(Show), migrating all impls of ToStr to fmt::Show.

Most of the details can be found in the first commit message.

Closes #12477
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/any.rs9
-rw-r--r--src/libstd/ascii.rs10
-rw-r--r--src/libstd/bool.rs17
-rw-r--r--src/libstd/char.rs10
-rw-r--r--src/libstd/fmt/mod.rs10
-rw-r--r--src/libstd/io/mod.rs42
-rw-r--r--src/libstd/io/net/ip.rs27
-rw-r--r--src/libstd/num/f32.rs6
-rw-r--r--src/libstd/num/f64.rs6
-rw-r--r--src/libstd/num/int_macros.rs8
-rw-r--r--src/libstd/num/uint_macros.rs8
-rw-r--r--src/libstd/option.rs15
-rw-r--r--src/libstd/path/mod.rs11
-rw-r--r--src/libstd/result.rs19
-rw-r--r--src/libstd/str.rs16
-rw-r--r--src/libstd/to_str.rs48
-rw-r--r--src/libstd/tuple.rs7
17 files changed, 32 insertions, 237 deletions
diff --git a/src/libstd/any.rs b/src/libstd/any.rs
index 06ae20d60bc..551a34fc87f 100644
--- a/src/libstd/any.rs
+++ b/src/libstd/any.rs
@@ -24,7 +24,6 @@ use cast::transmute;
 use fmt;
 use option::{Option, Some, None};
 use result::{Result, Ok, Err};
-use to_str::ToStr;
 use intrinsics::TypeId;
 use intrinsics;
 
@@ -151,14 +150,6 @@ impl AnyOwnExt for ~Any {
 // Trait implementations
 ///////////////////////////////////////////////////////////////////////////////
 
-impl ToStr for ~Any {
-    fn to_str(&self) -> ~str { ~"~Any" }
-}
-
-impl<'a> ToStr for &'a Any {
-    fn to_str(&self) -> ~str { ~"&Any" }
-}
-
 impl fmt::Show for ~Any {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.pad("~Any")
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs
index 1ae36ab46aa..ac24a02c15b 100644
--- a/src/libstd/ascii.rs
+++ b/src/libstd/ascii.rs
@@ -10,7 +10,7 @@
 
 //! Operations on ASCII strings and characters
 
-use to_str::{ToStr, IntoStr};
+use to_str::{IntoStr};
 use str;
 use str::Str;
 use str::StrSlice;
@@ -127,14 +127,6 @@ impl Ascii {
     }
 }
 
-impl ToStr for Ascii {
-    #[inline]
-    fn to_str(&self) -> ~str {
-        // self.chr is always a valid utf8 byte, no need for the check
-        unsafe { str::raw::from_byte(self.chr) }
-    }
-}
-
 impl<'a> fmt::Show for Ascii {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         (self.chr as char).fmt(f)
diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs
index af745f94fb5..918d42e1bce 100644
--- a/src/libstd/bool.rs
+++ b/src/libstd/bool.rs
@@ -17,7 +17,6 @@
 //! Implementations of the following traits:
 //!
 //! * `FromStr`
-//! * `ToStr`
 //! * `Not`
 //! * `Ord`
 //! * `TotalOrd`
@@ -34,7 +33,6 @@
 
 use option::{None, Option, Some};
 use from_str::FromStr;
-use to_str::ToStr;
 use num::FromPrimitive;
 
 #[cfg(not(test))] use cmp::{Eq, Ord, TotalOrd, Ordering};
@@ -179,21 +177,6 @@ impl FromStr for bool {
     }
 }
 
-impl ToStr for bool {
-    /// Convert a `bool` to a string.
-    ///
-    /// # Examples
-    ///
-    /// ```rust
-    /// assert_eq!(true.to_str(), ~"true");
-    /// assert_eq!(false.to_str(), ~"false");
-    /// ```
-    #[inline]
-    fn to_str(&self) -> ~str {
-        if *self { ~"true" } else { ~"false" }
-    }
-}
-
 #[cfg(not(test))]
 impl Not<bool> for bool {
     /// The logical complement of a boolean value.
diff --git a/src/libstd/char.rs b/src/libstd/char.rs
index 1ec89d1850f..ed2a88e644b 100644
--- a/src/libstd/char.rs
+++ b/src/libstd/char.rs
@@ -15,8 +15,6 @@ use option::{None, Option, Some};
 use iter::{Iterator, range_step};
 use str::StrSlice;
 use unicode::{derived_property, property, general_category, decompose};
-use to_str::ToStr;
-use str;
 
 #[cfg(test)] use str::OwnedStr;
 
@@ -344,13 +342,6 @@ pub fn len_utf8_bytes(c: char) -> uint {
     }
 }
 
-impl ToStr for char {
-    #[inline]
-    fn to_str(&self) -> ~str {
-        str::from_char(*self)
-    }
-}
-
 #[allow(missing_doc)]
 pub trait Char {
     fn is_alphabetic(&self) -> bool;
@@ -556,6 +547,7 @@ fn test_escape_unicode() {
 
 #[test]
 fn test_to_str() {
+    use to_str::ToStr;
     let s = 't'.to_str();
     assert_eq!(s, ~"t");
 }
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs
index a55794b08fe..5c0838fadca 100644
--- a/src/libstd/fmt/mod.rs
+++ b/src/libstd/fmt/mod.rs
@@ -1055,6 +1055,16 @@ pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> {
 
 // Implementations of the core formatting traits
 
+impl<T: Show> Show for @T {
+    fn fmt(&self, f: &mut Formatter) -> Result { secret_show(&**self, f) }
+}
+impl<T: Show> Show for ~T {
+    fn fmt(&self, f: &mut Formatter) -> Result { secret_show(&**self, f) }
+}
+impl<'a, T: Show> Show for &'a T {
+    fn fmt(&self, f: &mut Formatter) -> Result { secret_show(*self, f) }
+}
+
 impl Bool for bool {
     fn fmt(&self, f: &mut Formatter) -> Result {
         secret_string(&(if *self {"true"} else {"false"}), f)
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index f4ff4dd7e5d..36d399476d9 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -188,7 +188,6 @@ use path::Path;
 use result::{Ok, Err, Result};
 use str::{StrSlice, OwnedStr};
 use str;
-use to_str::ToStr;
 use uint;
 use unstable::finally::try_finally;
 use vec::{OwnedVector, MutableVector, ImmutableVector, OwnedCloneableVector};
@@ -286,21 +285,7 @@ impl fmt::Show for IoError {
     }
 }
 
-// FIXME: #8242 implementing manually because deriving doesn't work for some reason
-impl ToStr for IoError {
-    fn to_str(&self) -> ~str {
-        let mut s = ~"IoError { kind: ";
-        s.push_str(self.kind.to_str());
-        s.push_str(", desc: ");
-        s.push_str(self.desc);
-        s.push_str(", detail: ");
-        s.push_str(self.detail.to_str());
-        s.push_str(" }");
-        s
-    }
-}
-
-#[deriving(Eq, Clone)]
+#[deriving(Eq, Clone, Show)]
 pub enum IoErrorKind {
     OtherIoError,
     EndOfFile,
@@ -321,31 +306,6 @@ pub enum IoErrorKind {
     InvalidInput,
 }
 
-// FIXME: #8242 implementing manually because deriving doesn't work for some reason
-impl ToStr for IoErrorKind {
-    fn to_str(&self) -> ~str {
-        match *self {
-            OtherIoError => ~"OtherIoError",
-            EndOfFile => ~"EndOfFile",
-            FileNotFound => ~"FileNotFound",
-            PermissionDenied => ~"PermissionDenied",
-            ConnectionFailed => ~"ConnectionFailed",
-            Closed => ~"Closed",
-            ConnectionRefused => ~"ConnectionRefused",
-            ConnectionReset => ~"ConnectionReset",
-            NotConnected => ~"NotConnected",
-            BrokenPipe => ~"BrokenPipe",
-            PathAlreadyExists => ~"PathAlreadyExists",
-            PathDoesntExist => ~"PathDoesntExist",
-            MismatchedFileTypeForOperation => ~"MismatchedFileTypeForOperation",
-            IoUnavailable => ~"IoUnavailable",
-            ResourceUnavailable => ~"ResourceUnavailable",
-            ConnectionAborted => ~"ConnectionAborted",
-            InvalidInput => ~"InvalidInput",
-        }
-    }
-}
-
 pub trait Reader {
 
     // Only method which need to get implemented for this trait
diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs
index 13ea552ab3b..e4f36764323 100644
--- a/src/libstd/io/net/ip.rs
+++ b/src/libstd/io/net/ip.rs
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 use container::Container;
+use fmt;
 use from_str::FromStr;
 use iter::Iterator;
 use option::{Option, None, Some};
 use str::StrSlice;
-use to_str::ToStr;
 use vec::{MutableCloneableVector, ImmutableVector, MutableVector};
 
 pub type Port = u16;
@@ -24,26 +24,27 @@ pub enum IpAddr {
     Ipv6Addr(u16, u16, u16, u16, u16, u16, u16, u16)
 }
 
-impl ToStr for IpAddr {
-    fn to_str(&self) -> ~str {
+impl fmt::Show for IpAddr {
+    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             Ipv4Addr(a, b, c, d) =>
-                format!("{}.{}.{}.{}", a, b, c, d),
+                write!(fmt.buf, "{}.{}.{}.{}", a, b, c, d),
 
             // Ipv4 Compatible address
             Ipv6Addr(0, 0, 0, 0, 0, 0, g, h) => {
-                format!("::{}.{}.{}.{}", (g >> 8) as u8, g as u8,
-                        (h >> 8) as u8, h as u8)
+                write!(fmt.buf, "::{}.{}.{}.{}", (g >> 8) as u8, g as u8,
+                       (h >> 8) as u8, h as u8)
             }
 
             // Ipv4-Mapped address
             Ipv6Addr(0, 0, 0, 0, 0, 0xFFFF, g, h) => {
-                format!("::FFFF:{}.{}.{}.{}", (g >> 8) as u8, g as u8,
-                        (h >> 8) as u8, h as u8)
+                write!(fmt.buf, "::FFFF:{}.{}.{}.{}", (g >> 8) as u8, g as u8,
+                       (h >> 8) as u8, h as u8)
             }
 
             Ipv6Addr(a, b, c, d, e, f, g, h) =>
-                format!("{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}", a, b, c, d, e, f, g, h)
+                write!(fmt.buf, "{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}:{:x}",
+                       a, b, c, d, e, f, g, h)
         }
     }
 }
@@ -55,11 +56,11 @@ pub struct SocketAddr {
 }
 
 
-impl ToStr for SocketAddr {
-    fn to_str(&self) -> ~str {
+impl fmt::Show for SocketAddr {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.ip {
-            Ipv4Addr(..) => format!("{}:{}", self.ip.to_str(), self.port),
-            Ipv6Addr(..) => format!("[{}]:{}", self.ip.to_str(), self.port),
+            Ipv4Addr(..) => write!(f.buf, "{}:{}", self.ip, self.port),
+            Ipv6Addr(..) => write!(f.buf, "[{}]:{}", self.ip, self.port),
         }
     }
 }
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs
index 7b1fe949199..a4eac564ee6 100644
--- a/src/libstd/num/f32.rs
+++ b/src/libstd/num/f32.rs
@@ -19,7 +19,6 @@ use libc::{c_float, c_int};
 use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
 use num::{Zero, One, Bounded, strconv};
 use num;
-use to_str;
 use intrinsics;
 
 macro_rules! delegate(
@@ -745,11 +744,6 @@ pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> ~str {
     r
 }
 
-impl to_str::ToStr for f32 {
-    #[inline]
-    fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
-}
-
 impl num::ToStrRadix for f32 {
     /// Converts a float to a string in a given radix
     ///
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index d5a571cdd23..e6b903cbbdb 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -20,7 +20,6 @@ use libc::{c_double, c_int};
 use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
 use num::{Zero, One, Bounded, strconv};
 use num;
-use to_str;
 use intrinsics;
 
 pub use cmp::{min, max};
@@ -747,11 +746,6 @@ pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> ~str {
     r
 }
 
-impl to_str::ToStr for f64 {
-    #[inline]
-    fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
-}
-
 impl num::ToStrRadix for f64 {
     /// Converts a float to a string in a given radix
     ///
diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs
index 43a70190812..030aa2d81fa 100644
--- a/src/libstd/num/int_macros.rs
+++ b/src/libstd/num/int_macros.rs
@@ -273,14 +273,6 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
     f(buf.slice(0, cur))
 }
 
-impl ToStr for $T {
-    /// Convert to a string in base 10.
-    #[inline]
-    fn to_str(&self) -> ~str {
-        format!("{:d}", *self)
-    }
-}
-
 impl ToStrRadix for $T {
     /// Convert to a string in a given base.
     #[inline]
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs
index d60b5235446..001927e6033 100644
--- a/src/libstd/num/uint_macros.rs
+++ b/src/libstd/num/uint_macros.rs
@@ -187,14 +187,6 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U {
     f(buf.slice(0, cur))
 }
 
-impl ToStr for $T {
-    /// Convert to a string in base 10.
-    #[inline]
-    fn to_str(&self) -> ~str {
-        format!("{:u}", *self)
-    }
-}
-
 impl ToStrRadix for $T {
     /// Convert to a string in a given base.
     #[inline]
diff --git a/src/libstd/option.rs b/src/libstd/option.rs
index 44d78be93d6..633d6e92c70 100644
--- a/src/libstd/option.rs
+++ b/src/libstd/option.rs
@@ -42,16 +42,13 @@ use clone::Clone;
 use clone::DeepClone;
 use cmp::{Eq, TotalEq, TotalOrd};
 use default::Default;
-use fmt;
 use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
 use kinds::Send;
 use mem;
-use str::OwnedStr;
-use to_str::ToStr;
 use vec;
 
 /// The option type
-#[deriving(Clone, DeepClone, Eq, Ord, TotalEq, TotalOrd, ToStr)]
+#[deriving(Clone, DeepClone, Eq, Ord, TotalEq, TotalOrd, Show)]
 pub enum Option<T> {
     /// No value
     None,
@@ -380,16 +377,6 @@ impl<T: Default> Option<T> {
 // Trait implementations
 /////////////////////////////////////////////////////////////////////////////
 
-impl<T: fmt::Show> fmt::Show for Option<T> {
-    #[inline]
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match *self {
-            Some(ref t) => write!(f.buf, "Some({})", *t),
-            None        => write!(f.buf, "None")
-        }
-    }
-}
-
 impl<T> Default for Option<T> {
     #[inline]
     fn default() -> Option<T> { None }
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index 13496033fd0..09124f63361 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -71,7 +71,6 @@ use iter::Iterator;
 use option::{Option, None, Some};
 use str;
 use str::{MaybeOwned, OwnedStr, Str, StrSlice, from_utf8_lossy};
-use to_str::ToStr;
 use vec;
 use vec::{CloneableVector, OwnedCloneableVector, OwnedVector, Vector};
 use vec::{ImmutableEqVector, ImmutableVector};
@@ -499,16 +498,6 @@ impl<'a, P: GenericPath> fmt::Show for Display<'a, P> {
     }
 }
 
-impl<'a, P: GenericPath> ToStr for Display<'a, P> {
-    /// Returns the path as a string
-    ///
-    /// If the path is not UTF-8, invalid sequences with be replaced with the
-    /// unicode replacement char. This involves allocation.
-    fn to_str(&self) -> ~str {
-        self.as_maybe_owned().into_owned()
-    }
-}
-
 impl<'a, P: GenericPath> Display<'a, P> {
     /// Returns the path as a possibly-owned string.
     ///
diff --git a/src/libstd/result.rs b/src/libstd/result.rs
index 39e8b6ad6c1..3f09351ead6 100644
--- a/src/libstd/result.rs
+++ b/src/libstd/result.rs
@@ -12,14 +12,11 @@
 
 use clone::Clone;
 use cmp::Eq;
-use fmt;
 use iter::{Iterator, FromIterator};
 use option::{None, Option, Some};
-use str::OwnedStr;
-use to_str::ToStr;
 
 /// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
-#[deriving(Clone, DeepClone, Eq, Ord, TotalEq, TotalOrd, ToStr)]
+#[deriving(Clone, DeepClone, Eq, Ord, TotalEq, TotalOrd, Show)]
 #[must_use]
 pub enum Result<T, E> {
     /// Contains the success value
@@ -203,20 +200,6 @@ impl<T, E> Result<T, E> {
 }
 
 /////////////////////////////////////////////////////////////////////////////
-// Trait implementations
-/////////////////////////////////////////////////////////////////////////////
-
-impl<T: fmt::Show, E: fmt::Show> fmt::Show for Result<T, E> {
-    #[inline]
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match *self {
-            Ok(ref t) => write!(f.buf, "Ok({})", *t),
-            Err(ref e) => write!(f.buf, "Err({})", *e)
-        }
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
 // Free functions
 /////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 3c094cd631d..daaf46be187 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -98,7 +98,6 @@ use num::Saturating;
 use option::{None, Option, Some};
 use ptr;
 use ptr::RawPtr;
-use to_str::ToStr;
 use from_str::FromStr;
 use vec;
 use vec::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector};
@@ -132,21 +131,11 @@ pub fn from_utf8<'a>(v: &'a [u8]) -> Option<&'a str> {
     } else { None }
 }
 
-impl ToStr for ~str {
-    #[inline]
-    fn to_str(&self) -> ~str { self.to_owned() }
-}
-
 impl FromStr for ~str {
     #[inline]
     fn from_str(s: &str) -> Option<~str> { Some(s.to_owned()) }
 }
 
-impl<'a> ToStr for &'a str {
-    #[inline]
-    fn to_str(&self) -> ~str { self.to_owned() }
-}
-
 /// Convert a byte to a UTF-8 string
 ///
 /// # Failure
@@ -1269,11 +1258,6 @@ impl<'a> IntoMaybeOwned<'a> for MaybeOwned<'a> {
     fn into_maybe_owned(self) -> MaybeOwned<'a> { self }
 }
 
-impl<'a> ToStr for MaybeOwned<'a> {
-    #[inline]
-    fn to_str(&self) -> ~str { self.as_slice().to_owned() }
-}
-
 impl<'a> Eq for MaybeOwned<'a> {
     #[inline]
     fn eq(&self, other: &MaybeOwned) -> bool {
diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs
index 46a9e93f416..ba3c1c0fc45 100644
--- a/src/libstd/to_str.rs
+++ b/src/libstd/to_str.rs
@@ -14,10 +14,7 @@ The `ToStr` trait for converting to strings
 
 */
 
-use option::{Some, None};
-use str::OwnedStr;
-use iter::Iterator;
-use vec::ImmutableVector;
+use fmt;
 
 /// A generic trait for converting a value to a string
 pub trait ToStr {
@@ -31,47 +28,8 @@ pub trait IntoStr {
     fn into_str(self) -> ~str;
 }
 
-impl ToStr for () {
-    #[inline]
-    fn to_str(&self) -> ~str { ~"()" }
-}
-
-impl<'a,A:ToStr> ToStr for &'a [A] {
-    #[inline]
-    fn to_str(&self) -> ~str {
-        let mut acc = ~"[";
-        let mut first = true;
-        for elt in self.iter() {
-            if first {
-                first = false;
-            }
-            else {
-                acc.push_str(", ");
-            }
-            acc.push_str(elt.to_str());
-        }
-        acc.push_char(']');
-        acc
-    }
-}
-
-impl<A:ToStr> ToStr for ~[A] {
-    #[inline]
-    fn to_str(&self) -> ~str {
-        let mut acc = ~"[";
-        let mut first = true;
-        for elt in self.iter() {
-            if first {
-                first = false;
-            }
-            else {
-                acc.push_str(", ");
-            }
-            acc.push_str(elt.to_str());
-        }
-        acc.push_char(']');
-        acc
-    }
+impl<T: fmt::Show> ToStr for T {
+    fn to_str(&self) -> ~str { format!("{}", *self) }
 }
 
 #[cfg(test)]
diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs
index b0d51cba103..9d50337efab 100644
--- a/src/libstd/tuple.rs
+++ b/src/libstd/tuple.rs
@@ -17,7 +17,6 @@ use clone::Clone;
 #[cfg(not(test))] use default::Default;
 use fmt;
 use result::{Ok, Err};
-use to_str::ToStr;
 
 // macro for implementing n-ary tuple functions and operations
 macro_rules! tuple_impls {
@@ -119,12 +118,6 @@ macro_rules! tuple_impls {
                 }
             }
 
-            impl<$($T: fmt::Show),+> ToStr for ($($T,)+) {
-                fn to_str(&self) -> ~str {
-                    format!("{}", *self)
-                }
-            }
-
             impl<$($T: fmt::Show),+> fmt::Show for ($($T,)+) {
                 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                     write_tuple!(f.buf, $(self.$refN()),+)