@@ -9,7 +9,7 @@ type pub copy enum Ordering {
9
9
case Greater
10
10
}
11
11
12
- impl Equal[ref Ordering] for Ordering {
12
+ impl Equal for Ordering {
13
13
fn pub inline ==(other: ref Ordering) -> Bool {
14
14
match (self, other) {
15
15
case (Less, Less) -> true
@@ -33,42 +33,42 @@ impl Format for Ordering {
33
33
}
34
34
35
35
# A type that can be compared to another type for a sort-order.
36
- trait pub Compare[T] {
36
+ trait pub Compare {
37
37
# Returns the ordering between `self` and the given argument.
38
38
#
39
39
# The returned value should be as follows:
40
40
#
41
41
# - `a == b`: `Ordering.Equal`
42
42
# - `a > b`: `Ordering.Greater`
43
43
# - `a < b`: `Ordering.Less`
44
- fn pub cmp(other: ref T ) -> Ordering
44
+ fn pub cmp(other: ref Self ) -> Ordering
45
45
46
46
# Returns `true` if `self` is lower than the given argument.
47
- fn pub <(other: ref T ) -> Bool {
47
+ fn pub <(other: ref Self ) -> Bool {
48
48
match cmp(other) {
49
49
case Less -> true
50
50
case _ -> false
51
51
}
52
52
}
53
53
54
54
# Returns `true` if `self` is lower than or equal to the given argument.
55
- fn pub <=(other: ref T ) -> Bool {
55
+ fn pub <=(other: ref Self ) -> Bool {
56
56
match cmp(other) {
57
57
case Less or Equal -> true
58
58
case _ -> false
59
59
}
60
60
}
61
61
62
62
# Returns `true` if `self` is greater than the given argument.
63
- fn pub >(other: ref T ) -> Bool {
63
+ fn pub >(other: ref Self ) -> Bool {
64
64
match cmp(other) {
65
65
case Greater -> true
66
66
case _ -> false
67
67
}
68
68
}
69
69
70
70
# Returns `true` if `self` is equal to or greater than the given argument.
71
- fn pub >=(other: ref T ) -> Bool {
71
+ fn pub >=(other: ref Self ) -> Bool {
72
72
match cmp(other) {
73
73
case Greater or Equal -> true
74
74
case _ -> false
@@ -77,18 +77,18 @@ trait pub Compare[T] {
77
77
}
78
78
79
79
# A type that can be compared for equality.
80
- trait pub Equal[T] {
80
+ trait pub Equal {
81
81
# Returns `true` if `self` and the given object are equal to each other.
82
82
#
83
83
# This operator is used to perform structural equality. This means two objects
84
84
# residing in different memory locations may be considered equal, provided
85
85
# their structure is equal. For example, two different arrays may be
86
86
# considered to have structural equality if they contain the exact same
87
87
# values.
88
- fn pub ==(other: T ) -> Bool
88
+ fn pub ==(other: ref Self ) -> Bool
89
89
90
90
# Returns `true` if `self` and the given object are not equal to each other.
91
- fn pub !=(other: T ) -> Bool {
91
+ fn pub !=(other: ref Self ) -> Bool {
92
92
(self == other).false?
93
93
}
94
94
}
@@ -108,7 +108,7 @@ trait pub Contains[T] {
108
108
#
109
109
# min(10, 5) # => 5
110
110
# ```
111
- fn pub inline min[T: Compare[T] ](a: T, b: T) -> T {
111
+ fn pub inline min[T: Compare](a: T, b: T) -> T {
112
112
if a <= b { a } else { b }
113
113
}
114
114
@@ -121,6 +121,6 @@ fn pub inline min[T: Compare[T]](a: T, b: T) -> T {
121
121
#
122
122
# max(10, 5) # => 10
123
123
# ```
124
- fn pub inline max[T: Compare[T] ](a: T, b: T) -> T {
124
+ fn pub inline max[T: Compare](a: T, b: T) -> T {
125
125
if a >= b { a } else { b }
126
126
}
0 commit comments