auto merge of #5547 : catamorphism/rust/issue-4898, r=catamorphism
This commit is contained in:
commit
5011d05db2
@ -451,6 +451,9 @@ impl TyVisitor for ReprVisitor {
|
||||
}
|
||||
fn visit_leave_tup(&self, _n_fields: uint,
|
||||
_sz: uint, _align: uint) -> bool {
|
||||
if _n_fields == 1 {
|
||||
self.writer.write_char(',');
|
||||
}
|
||||
self.writer.write_char(')');
|
||||
true
|
||||
}
|
||||
@ -591,7 +594,6 @@ fn test_repr() {
|
||||
fail_unless!(s == e);
|
||||
}
|
||||
|
||||
|
||||
exact_test(&10, "10");
|
||||
exact_test(&true, "true");
|
||||
exact_test(&false, "false");
|
||||
@ -608,6 +610,7 @@ fn test_repr() {
|
||||
let mut x = 10;
|
||||
exact_test(&(&mut x), "&mut 10");
|
||||
|
||||
exact_test(&(1,), "(1,)");
|
||||
exact_test(&(@[1,2,3,4,5,6,7,8]),
|
||||
"@[1, 2, 3, 4, 5, 6, 7, 8]");
|
||||
exact_test(&(@[1u8,2u8,3u8,4u8]),
|
||||
|
@ -29,7 +29,16 @@ impl ToStr for () {
|
||||
fn to_str(&self) -> ~str { ~"()" }
|
||||
}
|
||||
|
||||
// FIXME #4898: impl for one-tuples
|
||||
impl<A:ToStr> ToStr for (A,) {
|
||||
#[inline(always)]
|
||||
fn to_str(&self) -> ~str {
|
||||
match *self {
|
||||
(ref a,) => {
|
||||
~"(" + a.to_str() + ~", " + ~")"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<A:ToStr,B:ToStr> ToStr for (A, B) {
|
||||
#[inline(always)]
|
||||
|
@ -112,7 +112,45 @@ impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME #4898: impl for one-tuples
|
||||
#[cfg(notest)]
|
||||
impl<A:Eq> Eq for (A,) {
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: &(A,)) -> bool {
|
||||
match (*self) {
|
||||
(ref self_a,) => match other {
|
||||
&(ref other_a,) => {
|
||||
(*self_a).eq(other_a)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[inline(always)]
|
||||
fn ne(&self, other: &(A,)) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<A:Ord> Ord for (A,) {
|
||||
#[inline(always)]
|
||||
fn lt(&self, other: &(A,)) -> bool {
|
||||
match (*self) {
|
||||
(ref self_a,) => {
|
||||
match (*other) {
|
||||
(ref other_a,) => {
|
||||
if (*self_a).lt(other_a) { return true; }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[inline(always)]
|
||||
fn le(&self, other: &(A,)) -> bool { !other.lt(&(*self)) }
|
||||
#[inline(always)]
|
||||
fn ge(&self, other: &(A,)) -> bool { !self.lt(other) }
|
||||
#[inline(always)]
|
||||
fn gt(&self, other: &(A,)) -> bool { other.lt(&(*self)) }
|
||||
}
|
||||
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<A:Eq,B:Eq> Eq for (A, B) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user