]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/unique-kinds.rs
auto merge of #20154 : P1start/rust/qualified-assoc-type-generics, r=nikomatsakis
[rust.git] / src / test / run-pass / unique-kinds.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use std::cmp::PartialEq;
12
13 fn sendable() {
14
15     fn f<T:Send + PartialEq>(i: T, j: T) {
16         assert!(i == j);
17     }
18
19     fn g<T:Send + PartialEq>(i: T, j: T) {
20         assert!(i != j);
21     }
22
23     let i = box 100i;
24     let j = box 100i;
25     f(i, j);
26     let i = box 100i;
27     let j = box 101i;
28     g(i, j);
29 }
30
31 fn copyable() {
32
33     fn f<T:PartialEq>(i: T, j: T) {
34         assert!(i == j);
35     }
36
37     fn g<T:PartialEq>(i: T, j: T) {
38         assert!(i != j);
39     }
40
41     let i = box 100i;
42     let j = box 100i;
43     f(i, j);
44     let i = box 100i;
45     let j = box 101i;
46     g(i, j);
47 }
48
49 fn noncopyable() {
50
51     fn f<T:PartialEq>(i: T, j: T) {
52         assert!(i == j);
53     }
54
55     fn g<T:PartialEq>(i: T, j: T) {
56         assert!(i != j);
57     }
58
59     let i = box 100i;
60     let j = box 100i;
61     f(i, j);
62     let i = box 100i;
63     let j = box 101i;
64     g(i, j);
65 }
66
67 pub fn main() {
68     sendable();
69     copyable();
70     noncopyable();
71 }