File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ //xfail-test
2
+
3
+ // Sketching traits.
4
+
5
+ // methods with no implementation are required; methods with an
6
+ // implementation are provided. No "req" keyword necessary.
7
+ trait Eq {
8
+ fn eq ( a: self ) -> bool ;
9
+
10
+ fn neq ( a: self ) -> bool {
11
+ !self . neq ( a)
12
+ }
13
+ }
14
+
15
+ // The `<` is pronounced `extends`. Also under consideration is `<:`.
16
+ // Just using `:` is frowned upon, because (paraphrasing dherman) `:`
17
+ // is supposed to separate things from different universes.
18
+ trait Ord < Eq {
19
+
20
+ fn lt ( a: self ) -> bool ;
21
+
22
+ fn lte ( a: self ) -> bool {
23
+ self . lt ( a) || self . eq ( a)
24
+ }
25
+
26
+ fn gt ( a: self ) -> bool {
27
+ !self . lt ( a) && !self . eq ( a)
28
+ }
29
+
30
+ fn gte ( a: self ) -> bool {
31
+ !self . lt ( a)
32
+ }
33
+ }
34
+
35
+ // pronounced "impl of Ord for int" -- not sold on this yet
36
+ impl int: Ord {
37
+ fn lt ( a: self ) -> bool {
38
+ self < a
39
+ }
40
+
41
+ // is this the place to put this?
42
+ fn eq ( a: self ) -> bool {
43
+ self == a
44
+ }
45
+ }
46
+
You can’t perform that action at this time.
0 commit comments