Skip to content

Commit 880e9b0

Browse files
committed
---
yaml --- r: 31226 b: refs/heads/dist-snap c: fe43d66 h: refs/heads/master v: v3
1 parent 1e715e7 commit 880e9b0

File tree

9 files changed

+35
-30
lines changed

9 files changed

+35
-30
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 000d12f4aff47528a44a7cd8d8a26b644ac91cb0
10+
refs/heads/dist-snap: fe43d6661387383db067c711e624a77df30004a2
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import option::{some, none};
66
import option = option::option;
77
import path = path::path;
88
import str::extensions;
9+
import tuple::extensions;
910
import vec::extensions;
1011
import option::extensions;
1112
import option_iter::extensions;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ unsafe fn key_to_key_value<T>(key: local_data_key<T>) -> *libc::c_void {
878878
// Keys are closures, which are (fnptr,envptr) pairs. Use fnptr.
879879
// Use reintepret_cast -- transmute would leak (forget) the closure.
880880
let pair: (*libc::c_void, *libc::c_void) = unsafe::reinterpret_cast(key);
881-
tuple::first(pair)
881+
pair.first()
882882
}
883883

884884
// If returning some(..), returns with @T with the map's reference. Careful!
Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
//! Operations on tuples
22
3-
/// Return the first element of a pair
4-
pure fn first<T:copy, U:copy>(pair: (T, U)) -> T {
5-
let (t, _) = pair;
6-
ret t;
7-
}
83

9-
/// Return the second element of a pair
10-
pure fn second<T:copy, U:copy>(pair: (T, U)) -> U {
11-
let (_, u) = pair;
12-
ret u;
13-
}
4+
impl extensions <T:copy, U:copy> for (T, U) {
5+
6+
/// Return the first element of self
7+
pure fn first() -> T {
8+
let (t, _) = self;
9+
ret t;
10+
}
11+
12+
/// Return the second element of self
13+
pure fn second() -> U {
14+
let (_, u) = self;
15+
ret u;
16+
}
17+
18+
/// Return the results of swapping the two elements of self
19+
pure fn swap() -> (U, T) {
20+
let (t, u) = self;
21+
ret (u, t);
22+
}
1423

15-
/// Return the results of swapping the two elements of a pair
16-
pure fn swap<T:copy, U:copy>(pair: (T, U)) -> (U, T) {
17-
let (t, u) = pair;
18-
ret (u, t);
1924
}
2025

2126

2227
#[test]
2328
fn test_tuple() {
24-
assert first((948, 4039.48)) == 948;
25-
assert second((34.5, ~"foo")) == ~"foo";
26-
assert swap(('a', 2)) == (2, 'a');
29+
assert (948, 4039.48).first() == 948;
30+
assert (34.5, ~"foo").second() == ~"foo";
31+
assert ('a', 2).swap() == (2, 'a');
2732
}
2833

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ fn merge_sort<T: copy>(le: le<T>, v: ~[const T]) -> ~[T] {
2222

2323
fn merge_sort_<T: copy>(le: le<T>, v: ~[const T], slice: slice)
2424
-> ~[T] {
25-
let begin = tuple::first(slice);
26-
let end = tuple::second(slice);
25+
let begin = slice.first();
26+
let end = slice.second();
2727

2828
let v_len = end - begin;
2929
if v_len == 0u { ret ~[]; }

branches/dist-snap/src/rustdoc/attr_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ fn merge_method_attrs(
229229
};
230230

231231
do vec::map2(docs, attrs) |doc, attrs| {
232-
assert doc.name == tuple::first(attrs);
233-
let desc = tuple::second(attrs);
232+
assert doc.name == attrs.first();
233+
let desc = attrs.second();
234234

235235
{
236236
desc: desc

branches/dist-snap/src/rustdoc/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn usage() {
6262
println(~"Usage: rustdoc ~[options] <cratefile>\n");
6363
println(~"Options:\n");
6464
for opts().each |opt| {
65-
println(#fmt(" %s", tuple::second(opt)));
65+
println(#fmt(" %s", opt.second()));
6666
}
6767
println(~"");
6868
}
@@ -99,7 +99,7 @@ fn parse_config_(
9999
program_output: program_output
100100
) -> result<config, ~str> {
101101
let args = vec::tail(args);
102-
let opts = tuple::first(vec::unzip(opts()));
102+
let opts = vec::unzip(opts()).first();
103103
alt getopts::getopts(args, opts) {
104104
result::ok(match) {
105105
if vec::len(match.free) == 1u {

branches/dist-snap/src/rustdoc/markdown_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ mod test {
801801
) -> ~str {
802802
let (writer_factory, po) = markdown_writer::future_writer_factory();
803803
write_markdown(doc, writer_factory);
804-
ret tuple::second(comm::recv(po));
804+
ret comm::recv(po).second();
805805
}
806806

807807
fn write_markdown_str_srv(
@@ -811,7 +811,7 @@ mod test {
811811
let (writer_factory, po) = markdown_writer::future_writer_factory();
812812
let pass = mk_pass(writer_factory);
813813
pass.f(srv, doc);
814-
ret tuple::second(comm::recv(po));
814+
ret comm::recv(po).second();
815815
}
816816

817817
#[test]

branches/dist-snap/src/test/bench/task-perf-alloc-unwind.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use std;
44

5-
import tuple::{first, second};
65
import std::list::{list, cons, nil};
76
import std::time::precise_time_s;
87

@@ -75,8 +74,8 @@ fn recurse_or_fail(depth: int, st: option<st>) {
7574
unique: ~cons((), @*st.unique),
7675
fn_box: fn@() -> @nillist { @cons((), fn_box()) },
7776
fn_unique: fn~() -> ~nillist { ~cons((), @*fn_unique()) },
78-
tuple: (@cons((), first(st.tuple)),
79-
~cons((), @*second(st.tuple))),
77+
tuple: (@cons((), st.tuple.first()),
78+
~cons((), @*st.tuple.second())),
8079
vec: st.vec + ~[@cons((), st.vec.last())],
8180
res: r(@cons((), st.res._l))
8281
})

0 commit comments

Comments
 (0)