2012-08-27 18:26:35 -05:00
|
|
|
use cmp::Eq;
|
|
|
|
|
2011-11-18 05:39:20 -06:00
|
|
|
fn sendable() {
|
2011-09-22 17:28:49 -05:00
|
|
|
|
2012-09-07 16:52:28 -05:00
|
|
|
fn f<T: Send Eq>(i: T, j: T) {
|
2011-09-22 17:28:49 -05:00
|
|
|
assert i == j;
|
|
|
|
}
|
|
|
|
|
2012-09-07 16:52:28 -05:00
|
|
|
fn g<T: Send Eq>(i: T, j: T) {
|
2011-09-22 17:28:49 -05:00
|
|
|
assert i != j;
|
|
|
|
}
|
|
|
|
|
|
|
|
let i = ~100;
|
|
|
|
let j = ~100;
|
|
|
|
f(i, j);
|
|
|
|
let i = ~100;
|
|
|
|
let j = ~101;
|
|
|
|
g(i, j);
|
|
|
|
}
|
|
|
|
|
2011-11-18 05:39:20 -06:00
|
|
|
fn copyable() {
|
2011-09-22 17:28:49 -05:00
|
|
|
|
2012-09-07 16:52:28 -05:00
|
|
|
fn f<T: Copy Eq>(i: T, j: T) {
|
2011-09-22 17:28:49 -05:00
|
|
|
assert i == j;
|
|
|
|
}
|
|
|
|
|
2012-09-07 16:52:28 -05:00
|
|
|
fn g<T: Copy Eq>(i: T, j: T) {
|
2011-09-22 17:28:49 -05:00
|
|
|
assert i != j;
|
|
|
|
}
|
|
|
|
|
|
|
|
let i = ~100;
|
|
|
|
let j = ~100;
|
|
|
|
f(i, j);
|
|
|
|
let i = ~100;
|
|
|
|
let j = ~101;
|
|
|
|
g(i, j);
|
|
|
|
}
|
|
|
|
|
2011-11-18 05:39:20 -06:00
|
|
|
fn noncopyable() {
|
2011-09-22 17:28:49 -05:00
|
|
|
|
2012-08-27 18:26:35 -05:00
|
|
|
fn f<T: Eq>(i: T, j: T) {
|
2011-09-22 17:28:49 -05:00
|
|
|
assert i == j;
|
|
|
|
}
|
|
|
|
|
2012-08-27 18:26:35 -05:00
|
|
|
fn g<T: Eq>(i: T, j: T) {
|
2011-09-22 17:28:49 -05:00
|
|
|
assert i != j;
|
|
|
|
}
|
|
|
|
|
|
|
|
let i = ~100;
|
|
|
|
let j = ~100;
|
|
|
|
f(i, j);
|
|
|
|
let i = ~100;
|
|
|
|
let j = ~101;
|
|
|
|
g(i, j);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2011-11-18 05:39:20 -06:00
|
|
|
sendable();
|
|
|
|
copyable();
|
|
|
|
noncopyable();
|
|
|
|
}
|