Skip to content

Commit 95a89cf

Browse files
committed
---
yaml --- r: 120041 b: refs/heads/dist-snap c: 92095d1 h: refs/heads/master i: 120039: 568004d v: v3
1 parent 5386213 commit 95a89cf

File tree

5 files changed

+33
-22
lines changed

5 files changed

+33
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 1a989d67697fe33e51e7209511e89ba7faaba21d
9+
refs/heads/dist-snap: 92095d125ab4353a7bae002b893c2bd1bd06e379
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ pub mod any;
4444
pub mod finally;
4545
pub mod raw;
4646
pub mod char;
47+
pub mod tuple;

branches/dist-snap/src/libstd/tuple.rs renamed to branches/dist-snap/src/libcore/tuple.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use clone::Clone;
1616
#[cfg(not(test))] use cmp::*;
1717
#[cfg(not(test))] use default::Default;
18-
use fmt;
19-
use result::{Ok, Err};
2018

2119
// macro for implementing n-ary tuple functions and operations
2220
macro_rules! tuple_impls {
@@ -112,12 +110,6 @@ macro_rules! tuple_impls {
112110
($({ let x: $T = Default::default(); x},)+)
113111
}
114112
}
115-
116-
impl<$($T: fmt::Show),+> fmt::Show for ($($T,)+) {
117-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
118-
write_tuple!(f.buf, $(self.$refN()),+)
119-
}
120-
}
121113
)+
122114
}
123115
}
@@ -144,18 +136,6 @@ macro_rules! lexical_cmp {
144136
($a:expr, $b:expr) => { ($a).cmp($b) };
145137
}
146138

147-
macro_rules! write_tuple {
148-
($buf:expr, $x:expr) => (
149-
write!($buf, "({},)", *$x)
150-
);
151-
($buf:expr, $hd:expr, $($tl:expr),+) => ({
152-
try!(write!($buf, "("));
153-
try!(write!($buf, "{}", *$hd));
154-
$(try!(write!($buf, ", {}", *$tl));)+
155-
write!($buf, ")")
156-
});
157-
}
158-
159139
tuple_impls! {
160140
Tuple1 {
161141
(val0, ref0, mut0) -> A { (a) => a }

branches/dist-snap/src/libstd/fmt/mod.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,36 @@ impl<T> Show for *mut T {
12421242
fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) }
12431243
}
12441244

1245+
macro_rules! peel(($name:ident, $($other:ident,)*) => (tuple!($($other,)*)))
1246+
1247+
macro_rules! tuple (
1248+
() => ();
1249+
( $($name:ident,)+ ) => (
1250+
impl<$($name:Show),*> Show for ($($name,)*) {
1251+
#[allow(uppercase_variables, dead_assignment)]
1252+
fn fmt(&self, f: &mut Formatter) -> Result {
1253+
try!(write!(f.buf, "("));
1254+
let ($(ref $name,)*) = *self;
1255+
let mut n = 0;
1256+
$(
1257+
if n > 0 {
1258+
try!(write!(f.buf, ", "));
1259+
}
1260+
try!(write!(f.buf, "{}", *$name));
1261+
n += 1;
1262+
)*
1263+
if n == 1 {
1264+
try!(write!(f.buf, ","));
1265+
}
1266+
write!(f.buf, ")")
1267+
}
1268+
}
1269+
peel!($($name,)*)
1270+
)
1271+
)
1272+
1273+
tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }
1274+
12451275
impl Show for Box<any::Any> {
12461276
fn fmt(&self, f: &mut Formatter) -> Result { f.pad("Box<Any>") }
12471277
}

branches/dist-snap/src/libstd/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ pub use core::intrinsics;
147147
pub use core::mem;
148148
pub use core::ptr;
149149
pub use core::raw;
150+
pub use core::tuple;
150151

151152
// Run tests with libgreen instead of libnative.
152153
//
@@ -192,7 +193,6 @@ pub mod prelude;
192193
#[path = "num/f64.rs"] pub mod f64;
193194

194195
pub mod bool;
195-
pub mod tuple;
196196

197197
pub mod slice;
198198
pub mod vec;

0 commit comments

Comments
 (0)