Skip to content

Implement Show for 1-12 element tuples and improve the std::tuple API #12313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/etc/vim/syntax/rust.vim
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,9 @@ syn keyword rustTrait Buffer Writer Reader Seek
syn keyword rustTrait Str StrVector StrSlice OwnedStr IntoMaybeOwned
syn keyword rustTrait IterBytes
syn keyword rustTrait ToStr IntoStr
syn keyword rustTrait CloneableTuple ImmutableTuple
syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12
syn keyword rustTrait ImmutableTuple1 ImmutableTuple2 ImmutableTuple3 ImmutableTuple4
syn keyword rustTrait ImmutableTuple5 ImmutableTuple6 ImmutableTuple7 ImmutableTuple8
syn keyword rustTrait ImmutableTuple9 ImmutableTuple10 ImmutableTuple11 ImmutableTuple12
syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector ImmutableCloneableVector
syn keyword rustTrait OwnedVector OwnedCloneableVector OwnedEqVector MutableVector
syn keyword rustTrait Vector VectorVector CloneableVector ImmutableVector
Expand Down
8 changes: 4 additions & 4 deletions src/libcollections/btree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,15 @@ impl<K: Clone + TotalOrd, V: Clone> Branch<K, V> {
let new_outcome = self.clone().rightmost_child.insert(k.clone(),
v.clone(),
ub.clone());
new_branch = new_outcome.clone().n0();
outcome = new_outcome.n1();
new_branch = new_outcome.clone().val0();
outcome = new_outcome.val1();
}
else {
let new_outcome = self.clone().elts[index.unwrap()].left.insert(k.clone(),
v.clone(),
ub.clone());
new_branch = new_outcome.clone().n0();
outcome = new_outcome.n1();
new_branch = new_outcome.clone().val0();
outcome = new_outcome.val1();
}
//Check to see whether a branch or a leaf was returned from the
//tree traversal.
Expand Down
4 changes: 2 additions & 2 deletions src/libnative/io/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*c_void| -> T) -> T {
let mut tmps = vec::with_capacity(env.len());

for pair in env.iter() {
let kv = format!("{}={}", pair.first(), pair.second());
let kv = format!("{}={}", *pair.ref0(), *pair.ref1());
tmps.push(kv.to_c_str());
}

Expand All @@ -553,7 +553,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*mut c_void| -> T) -> T {
let mut blk = ~[];

for pair in env.iter() {
let kv = format!("{}={}", pair.first(), pair.second());
let kv = format!("{}={}", *pair.ref0(), *pair.ref1());
blk.push_all(kv.as_bytes());
blk.push(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr,
const_eval::const_uint(i) => i as uint,
_ => cx.sess.span_bug(count.span, "count must be integral const expression.")
};
let vs = vec::from_elem(n, const_expr(cx, elem, is_local).first());
let vs = vec::from_elem(n, const_expr(cx, elem, is_local).val0());
let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) {
C_struct(vs, false)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4604,7 +4604,7 @@ pub fn determine_inherited_purity(parent: (ast::Purity, ast::NodeId),
// purity inferred for it, then check it under its parent's purity.
// Otherwise, use its own
match child_sigil {
ast::BorrowedSigil if child.first() == ast::ImpureFn => parent,
ast::BorrowedSigil if child.val0() == ast::ImpureFn => parent,
_ => child
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1379,11 +1379,11 @@ fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
match c.impls.find(&it.id) {
Some(v) => {
let mut non_trait = v.iter().filter(|p| {
p.n0_ref().trait_.is_none()
p.ref0().trait_.is_none()
});
let non_trait = non_trait.to_owned_vec();
let mut traits = v.iter().filter(|p| {
p.n0_ref().trait_.is_some()
p.ref0().trait_.is_some()
});
let traits = traits.to_owned_vec();

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
let mut pm = plugins::PluginManager::new(Path::new(path));
for pass in passes.iter() {
let plugin = match PASSES.iter().position(|&(p, _, _)| p == *pass) {
Some(i) => PASSES[i].n1(),
Some(i) => PASSES[i].val1(),
None => {
error!("unknown pass {}, skipping", *pass);
continue
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2611,7 +2611,7 @@ mod tests {
assert_eq!(vi.size_hint(), (10, Some(10)));

assert_eq!(c.take(5).size_hint(), (5, Some(5)));
assert_eq!(c.skip(5).size_hint().second(), None);
assert_eq!(c.skip(5).size_hint().val1(), None);
assert_eq!(c.take_while(|_| false).size_hint(), (0, None));
assert_eq!(c.skip_while(|_| false).size_hint(), (0, None));
assert_eq!(c.enumerate().size_hint(), (uint::MAX, None));
Expand Down
4 changes: 0 additions & 4 deletions src/libstd/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ pub use io::{Buffer, Writer, Reader, Seek};
pub use str::{Str, StrVector, StrSlice, OwnedStr, IntoMaybeOwned};
pub use to_bytes::IterBytes;
pub use to_str::{ToStr, IntoStr};
pub use tuple::{CloneableTuple, ImmutableTuple};
pub use tuple::{ImmutableTuple1, ImmutableTuple2, ImmutableTuple3, ImmutableTuple4};
pub use tuple::{ImmutableTuple5, ImmutableTuple6, ImmutableTuple7, ImmutableTuple8};
pub use tuple::{ImmutableTuple9, ImmutableTuple10, ImmutableTuple11, ImmutableTuple12};
pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,14 @@ impl<'a> Iterator<&'a str> for StrSplits<'a> {
// Helper functions used for Unicode normalization
fn canonical_sort(comb: &mut [(char, u8)]) {
use iter::range;
use tuple::CloneableTuple;
use tuple::Tuple2;

let len = comb.len();
for i in range(0, len) {
let mut swapped = false;
for j in range(1, len-i) {
let classA = comb[j-1].second();
let classB = comb[j].second();
let classA = *comb[j-1].ref1();
let classB = *comb[j].ref1();
if classA != 0 && classB != 0 && classA > classB {
comb.swap(j-1, j);
swapped = true;
Expand Down
48 changes: 0 additions & 48 deletions src/libstd/to_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ impl ToStr for () {
fn to_str(&self) -> ~str { ~"()" }
}

impl<A:ToStr> ToStr for (A,) {
#[inline]
fn to_str(&self) -> ~str {
match *self {
(ref a,) => {
format!("({},)", (*a).to_str())
}
}
}
}

impl<A:ToStr+Hash+Eq, B:ToStr> ToStr for HashMap<A, B> {
#[inline]
fn to_str(&self) -> ~str {
Expand Down Expand Up @@ -91,36 +80,6 @@ impl<A:ToStr+Hash+Eq> ToStr for HashSet<A> {
}
}

impl<A:ToStr,B:ToStr> ToStr for (A, B) {
#[inline]
fn to_str(&self) -> ~str {
// FIXME(#4653): this causes an llvm assertion
//let &(ref a, ref b) = self;
match *self {
(ref a, ref b) => {
format!("({}, {})", (*a).to_str(), (*b).to_str())
}
}
}
}

impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
#[inline]
fn to_str(&self) -> ~str {
// FIXME(#4653): this causes an llvm assertion
//let &(ref a, ref b, ref c) = self;
match *self {
(ref a, ref b, ref c) => {
format!("({}, {}, {})",
(*a).to_str(),
(*b).to_str(),
(*c).to_str()
)
}
}
}
}

impl<'a,A:ToStr> ToStr for &'a [A] {
#[inline]
fn to_str(&self) -> ~str {
Expand Down Expand Up @@ -178,13 +137,6 @@ mod tests {
assert_eq!((~"hi").to_str(), ~"hi");
}

#[test]
fn test_tuple_types() {
assert_eq!((1, 2).to_str(), ~"(1, 2)");
assert_eq!((~"a", ~"b", false).to_str(), ~"(a, b, false)");
assert_eq!(((), ((), 100)).to_str(), ~"((), ((), 100))");
}

#[test]
fn test_vectors() {
let x: ~[int] = ~[];
Expand Down
Loading