Skip to content

Commit b712fa8

Browse files
committed
---
yaml --- r: 113212 b: refs/heads/snap-stage3 c: 92095d1 h: refs/heads/master v: v3
1 parent 9f52384 commit b712fa8

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: abdacecdf86b4b5a4f432560445a24e1c5f4751b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 1a989d67697fe33e51e7209511e89ba7faaba21d
4+
refs/heads/snap-stage3: 92095d125ab4353a7bae002b893c2bd1bd06e379
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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/snap-stage3/src/libstd/tuple.rs renamed to branches/snap-stage3/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/snap-stage3/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/snap-stage3/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)