]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/unique-kinds.rs
6bb1fdcf5627a5b72a20644832bff3bc7171a848
[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 #![allow(unknown_features)]
12 #![feature(box_syntax)]
13
14 use std::cmp::PartialEq;
15
16 fn sendable() {
17
18     fn f<T:Send + PartialEq>(i: T, j: T) {
19         assert!(i == j);
20     }
21
22     fn g<T:Send + PartialEq>(i: T, j: T) {
23         assert!(i != j);
24     }
25
26     let i: Box<_> = box 100;
27     let j: Box<_> = box 100;
28     f(i, j);
29     let i: Box<_> = box 100;
30     let j: Box<_> = box 101;
31     g(i, j);
32 }
33
34 fn copyable() {
35
36     fn f<T:PartialEq>(i: T, j: T) {
37         assert!(i == j);
38     }
39
40     fn g<T:PartialEq>(i: T, j: T) {
41         assert!(i != j);
42     }
43
44     let i: Box<_> = box 100;
45     let j: Box<_> = box 100;
46     f(i, j);
47     let i: Box<_> = box 100;
48     let j: Box<_> = box 101;
49     g(i, j);
50 }
51
52 fn noncopyable() {
53
54     fn f<T:PartialEq>(i: T, j: T) {
55         assert!(i == j);
56     }
57
58     fn g<T:PartialEq>(i: T, j: T) {
59         assert!(i != j);
60     }
61
62     let i: Box<_> = box 100;
63     let j: Box<_> = box 100;
64     f(i, j);
65     let i: Box<_> = box 100;
66     let j: Box<_> = box 101;
67     g(i, j);
68 }
69
70 pub fn main() {
71     sendable();
72     copyable();
73     noncopyable();
74 }