Skip to content

Commit 4c03ef9

Browse files
Lenny222nikomatsakis
authored andcommitted
---
yaml --- r: 7374 b: refs/heads/master c: 106dcf7 h: refs/heads/master v: v3
1 parent 35ae2fe commit 4c03ef9

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: a83ad1b9e657307f395361be0c687a4690bbcd6f
2+
refs/heads/master: 106dcf7b925a1ac654d5df36ea6227fead493124

trunk/src/libstd/std.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export c_vec, four, tri, util;
1212
export bitv, deque, fun_treemap, list, map, smallintmap, sort, treemap, ufind;
1313
export rope;
1414
export ebml, dbg, getopts, json, rand, sha1, term, time;
15-
export extfmt, test, tempfile;
15+
export extfmt, test, tempfile, tuple;
1616
// FIXME: generic_os and os_fs shouldn't be exported
1717
export generic_os, os, os_fs;
1818

@@ -61,6 +61,7 @@ mod md4;
6161
mod tempfile;
6262
mod term;
6363
mod time;
64+
mod tuple;
6465

6566
#[cfg(unicode)]
6667
mod unicode;

trunk/src/libstd/tuple.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Module: tuple
3+
*/
4+
5+
// FIXME #1546: Would rather write fst<T, U>(+pair: (T, U)) -> T
6+
fn first<T:copy, U:copy>(pair: (T, U)) -> T {
7+
let (t, _) = pair;
8+
ret t;
9+
}
10+
11+
fn second<T:copy, U:copy>(pair: (T, U)) -> U {
12+
let (_, u) = pair;
13+
ret u;
14+
}
15+
16+
fn swap<T:copy, U:copy>(pair: (T, U)) -> (U, T) {
17+
let (t, u) = pair;
18+
ret (u, t);
19+
}
20+
21+
22+
#[test]
23+
fn test_tuple() {
24+
assert first((948, 4039.48)) == 948;
25+
assert second((34.5, "foo")) == "foo";
26+
assert swap(('a', 2)) == (2, 'a');
27+
}
28+

trunk/src/rustdoc/attr_parser.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import rustc::syntax::ast;
22
import rustc::front::attr;
3+
import std::tuple;
34

45
export fn_attrs, arg_attrs;
56
export parse_fn;
@@ -83,8 +84,8 @@ fn parse_fn_(
8384
vec::filter_map(items) {|item|
8485
option::map(attr::name_value_str_pair(item)) { |pair|
8586
{
86-
name: util::fst(pair),
87-
desc: util::snd(pair)
87+
name: tuple::first(pair),
88+
desc: tuple::second(pair)
8889
}
8990
}
9091
}
@@ -172,4 +173,4 @@ mod tests {
172173
assert attrs.args[0] == {name: "a", desc: "arg a"};
173174
assert attrs.args[1] == {name: "b", desc: "arg b"};
174175
}
175-
}
176+
}

trunk/src/rustdoc/util.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +0,0 @@
1-
// FIXME #1546: Would rather write fst<T, U>(+pair: (T, U)) -> T
2-
fn fst<T:copy, U:copy>(pair: (T, U)) -> T {
3-
let (t, _) = pair;
4-
ret t;
5-
}
6-
7-
fn snd<T:copy, U:copy>(pair: (T, U)) -> U {
8-
let (_, u) = pair;
9-
ret u;
10-
}

0 commit comments

Comments
 (0)