spin-off rustdocs tuple code to libstd
This commit is contained in:
parent
a83ad1b9e6
commit
106dcf7b92
|
@ -12,7 +12,7 @@ export c_vec, four, tri, util;
|
|||
export bitv, deque, fun_treemap, list, map, smallintmap, sort, treemap, ufind;
|
||||
export rope;
|
||||
export ebml, dbg, getopts, json, rand, sha1, term, time;
|
||||
export extfmt, test, tempfile;
|
||||
export extfmt, test, tempfile, tuple;
|
||||
// FIXME: generic_os and os_fs shouldn't be exported
|
||||
export generic_os, os, os_fs;
|
||||
|
||||
|
@ -61,6 +61,7 @@ mod md4;
|
|||
mod tempfile;
|
||||
mod term;
|
||||
mod time;
|
||||
mod tuple;
|
||||
|
||||
#[cfg(unicode)]
|
||||
mod unicode;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Module: tuple
|
||||
*/
|
||||
|
||||
// FIXME #1546: Would rather write fst<T, U>(+pair: (T, U)) -> T
|
||||
fn first<T:copy, U:copy>(pair: (T, U)) -> T {
|
||||
let (t, _) = pair;
|
||||
ret t;
|
||||
}
|
||||
|
||||
fn second<T:copy, U:copy>(pair: (T, U)) -> U {
|
||||
let (_, u) = pair;
|
||||
ret u;
|
||||
}
|
||||
|
||||
fn swap<T:copy, U:copy>(pair: (T, U)) -> (U, T) {
|
||||
let (t, u) = pair;
|
||||
ret (u, t);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_tuple() {
|
||||
assert first((948, 4039.48)) == 948;
|
||||
assert second((34.5, "foo")) == "foo";
|
||||
assert swap(('a', 2)) == (2, 'a');
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import rustc::syntax::ast;
|
||||
import rustc::front::attr;
|
||||
import std::tuple;
|
||||
|
||||
export fn_attrs, arg_attrs;
|
||||
export parse_fn;
|
||||
|
@ -83,8 +84,8 @@ fn parse_fn_(
|
|||
vec::filter_map(items) {|item|
|
||||
option::map(attr::name_value_str_pair(item)) { |pair|
|
||||
{
|
||||
name: util::fst(pair),
|
||||
desc: util::snd(pair)
|
||||
name: tuple::first(pair),
|
||||
desc: tuple::second(pair)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,4 +173,4 @@ mod tests {
|
|||
assert attrs.args[0] == {name: "a", desc: "arg a"};
|
||||
assert attrs.args[1] == {name: "b", desc: "arg b"};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
// FIXME #1546: Would rather write fst<T, U>(+pair: (T, U)) -> T
|
||||
fn fst<T:copy, U:copy>(pair: (T, U)) -> T {
|
||||
let (t, _) = pair;
|
||||
ret t;
|
||||
}
|
||||
|
||||
fn snd<T:copy, U:copy>(pair: (T, U)) -> U {
|
||||
let (_, u) = pair;
|
||||
ret u;
|
||||
}
|
Loading…
Reference in New Issue