@@ -211,18 +211,18 @@ fn from_mut<T>(+v: [mut T]) -> [T] unsafe {
211
211
pure fn head < T : copy > ( v : [ const T ] /& ) -> T { v[ 0 ] }
212
212
213
213
#[ doc = "Returns a vector containing all but the first element of a slice" ]
214
- fn tail < T : copy > ( v : [ const T ] /& ) -> [ T ] {
214
+ pure fn tail < T : copy > ( v : [ const T ] /& ) -> [ T ] {
215
215
ret slice ( v, 1 u, len ( v) ) ;
216
216
}
217
217
218
218
#[ doc = "Returns a vector containing all but the first `n` \
219
219
elements of a slice"]
220
- fn tailn < T : copy > ( v : [ const T ] /& , n : uint ) -> [ T ] {
220
+ pure fn tailn < T : copy > ( v : [ const T ] /& , n : uint ) -> [ T ] {
221
221
slice ( v, n, len ( v) )
222
222
}
223
223
224
224
#[ doc = "Returns a vector containing all but the last element of a slice" ]
225
- fn init < T : copy > ( v : [ const T ] /& ) -> [ T ] {
225
+ pure fn init < T : copy > ( v : [ const T ] /& ) -> [ T ] {
226
226
assert len( v) != 0 u;
227
227
slice ( v, 0 u, len ( v) - 1 u)
228
228
}
@@ -1033,10 +1033,10 @@ pure fn unpack_mut_slice<T,U>(s: [mut T]/&,
1033
1033
impl extensions /& < T > for [ const T ] /& {
1034
1034
#[ doc = "Returns true if a vector contains no elements" ]
1035
1035
#[ inline]
1036
- fn is_empty ( ) -> bool { is_empty ( self ) }
1036
+ pure fn is_empty ( ) -> bool { is_empty ( self ) }
1037
1037
#[ doc = "Returns true if a vector contains some elements" ]
1038
1038
#[ inline]
1039
- fn is_not_empty ( ) -> bool { is_not_empty ( self ) }
1039
+ pure fn is_not_empty ( ) -> bool { is_not_empty ( self ) }
1040
1040
#[ doc = "Returns the length of a vector" ]
1041
1041
#[ inline]
1042
1042
pure fn len ( ) -> uint { len ( self ) }
@@ -1046,44 +1046,44 @@ impl extensions/&<T> for [const T]/& {
1046
1046
impl extensions /& < T : copy > for [ const T ] /& {
1047
1047
#[ doc = "Returns the first element of a vector" ]
1048
1048
#[ inline]
1049
- fn head ( ) -> T { head ( self ) }
1049
+ pure fn head ( ) -> T { head ( self ) }
1050
1050
#[ doc = "Returns all but the last elemnt of a vector" ]
1051
1051
#[ inline]
1052
- fn init ( ) -> [ T ] { init ( self ) }
1052
+ pure fn init ( ) -> [ T ] { init ( self ) }
1053
1053
#[ doc = "
1054
1054
Returns the last element of a `v`, failing if the vector is empty.
1055
1055
" ]
1056
1056
#[ inline]
1057
- fn last ( ) -> T { last ( self ) }
1057
+ pure fn last ( ) -> T { last ( self ) }
1058
1058
#[ doc = "Returns a copy of the elements from [`start`..`end`) from `v`." ]
1059
1059
#[ inline]
1060
- fn slice ( start : uint , end : uint ) -> [ T ] { slice ( self , start, end) }
1060
+ pure fn slice ( start : uint , end : uint ) -> [ T ] { slice ( self , start, end) }
1061
1061
#[ doc = "Returns all but the first element of a vector" ]
1062
1062
#[ inline]
1063
- fn tail ( ) -> [ T ] { tail ( self ) }
1063
+ pure fn tail ( ) -> [ T ] { tail ( self ) }
1064
1064
}
1065
1065
1066
1066
#[ doc = "Extension methods for vectors" ]
1067
1067
impl extensions /& < T > for [ T ] /& {
1068
1068
#[ doc = "Reduce a vector from right to left" ]
1069
1069
#[ inline]
1070
- fn foldr < U : copy > ( z : U , p : fn ( T , U ) -> U ) -> U { foldr ( self , z, p) }
1070
+ pure fn foldr < U : copy > ( z : U , p : fn ( T , U ) -> U ) -> U { foldr ( self , z, p) }
1071
1071
#[ doc = "
1072
1072
Iterates over a vector
1073
1073
1074
1074
Iterates over vector `v` and, for each element, calls function `f` with
1075
1075
the element's value.
1076
1076
" ]
1077
1077
#[ inline]
1078
- fn iter ( f : fn ( T ) ) { iter ( self , f) }
1078
+ pure fn iter ( f : fn ( T ) ) { iter ( self , f) }
1079
1079
#[ doc = "
1080
1080
Iterates over a vector's elements and indexes
1081
1081
1082
1082
Iterates over vector `v` and, for each element, calls function `f` with
1083
1083
the element's value and index.
1084
1084
" ]
1085
1085
#[ inline]
1086
- fn iteri ( f : fn ( uint , T ) ) { iteri ( self , f) }
1086
+ pure fn iteri ( f : fn ( uint , T ) ) { iteri ( self , f) }
1087
1087
#[ doc = "
1088
1088
Find the first index matching some predicate
1089
1089
@@ -1092,26 +1092,26 @@ impl extensions/&<T> for [T]/& {
1092
1092
elements then none is returned.
1093
1093
" ]
1094
1094
#[ inline]
1095
- fn position ( f : fn ( T ) -> bool ) -> option < uint > { position ( self , f) }
1095
+ pure fn position ( f : fn ( T ) -> bool ) -> option < uint > { position ( self , f) }
1096
1096
#[ doc = "Find the first index containing a matching value" ]
1097
1097
#[ inline]
1098
- fn position_elem ( x : T ) -> option < uint > { position_elem ( self , x) }
1098
+ pure fn position_elem ( x : T ) -> option < uint > { position_elem ( self , x) }
1099
1099
#[ doc = "
1100
1100
Iterates over a vector in reverse
1101
1101
1102
1102
Iterates over vector `v` and, for each element, calls function `f` with
1103
1103
the element's value.
1104
1104
" ]
1105
1105
#[ inline]
1106
- fn riter ( f : fn ( T ) ) { riter ( self , f) }
1106
+ pure fn riter ( f : fn ( T ) ) { riter ( self , f) }
1107
1107
#[ doc ="
1108
1108
Iterates over a vector's elements and indexes in reverse
1109
1109
1110
1110
Iterates over vector `v` and, for each element, calls function `f` with
1111
1111
the element's value and index.
1112
1112
" ]
1113
1113
#[ inline]
1114
- fn riteri ( f : fn ( uint , T ) ) { riteri ( self , f) }
1114
+ pure fn riteri ( f : fn ( uint , T ) ) { riteri ( self , f) }
1115
1115
#[ doc = "
1116
1116
Find the last index matching some predicate
1117
1117
@@ -1120,20 +1120,20 @@ impl extensions/&<T> for [T]/& {
1120
1120
matches no elements then none is returned.
1121
1121
" ]
1122
1122
#[ inline]
1123
- fn rposition ( f : fn ( T ) -> bool ) -> option < uint > { rposition ( self , f) }
1123
+ pure fn rposition ( f : fn ( T ) -> bool ) -> option < uint > { rposition ( self , f) }
1124
1124
#[ doc = "Find the last index containing a matching value" ]
1125
1125
#[ inline]
1126
- fn rposition_elem ( x : T ) -> option < uint > { rposition_elem ( self , x) }
1126
+ pure fn rposition_elem ( x : T ) -> option < uint > { rposition_elem ( self , x) }
1127
1127
#[ doc = "
1128
1128
Apply a function to each element of a vector and return the results
1129
1129
" ]
1130
1130
#[ inline]
1131
- fn map < U > ( f : fn ( T ) -> U ) -> [ U ] { map ( self , f) }
1131
+ pure fn map < U > ( f : fn ( T ) -> U ) -> [ U ] { map ( self , f) }
1132
1132
#[ doc = "
1133
1133
Apply a function to the index and value of each element in the vector
1134
1134
and return the results
1135
1135
" ]
1136
- fn mapi < U > ( f : fn ( uint , T ) -> U ) -> [ U ] {
1136
+ pure fn mapi < U > ( f : fn ( uint , T ) -> U ) -> [ U ] {
1137
1137
mapi ( self , f)
1138
1138
}
1139
1139
#[ doc = "Returns true if the function returns true for all elements.
@@ -1147,15 +1147,15 @@ impl extensions/&<T> for [T]/& {
1147
1147
of each result vector
1148
1148
" ]
1149
1149
#[ inline]
1150
- fn flat_map < U > ( f : fn ( T ) -> [ U ] ) -> [ U ] { flat_map ( self , f) }
1150
+ pure fn flat_map < U > ( f : fn ( T ) -> [ U ] ) -> [ U ] { flat_map ( self , f) }
1151
1151
#[ doc = "
1152
1152
Apply a function to each element of a vector and return the results
1153
1153
1154
1154
If function `f` returns `none` then that element is excluded from
1155
1155
the resulting vector.
1156
1156
" ]
1157
1157
#[ inline]
1158
- fn filter_map < U : copy > ( f : fn ( T ) -> option < U > ) -> [ U ] {
1158
+ pure fn filter_map < U : copy > ( f : fn ( T ) -> option < U > ) -> [ U ] {
1159
1159
filter_map ( self , f)
1160
1160
}
1161
1161
}
@@ -1170,7 +1170,7 @@ impl extensions/&<T: copy> for [T]/& {
1170
1170
only those elements for which `f` returned true.
1171
1171
" ]
1172
1172
#[ inline]
1173
- fn filter ( f : fn ( T ) -> bool ) -> [ T ] { filter ( self , f) }
1173
+ pure fn filter ( f : fn ( T ) -> bool ) -> [ T ] { filter ( self , f) }
1174
1174
#[ doc = "
1175
1175
Search for the first element that matches a given predicate
1176
1176
@@ -1179,7 +1179,7 @@ impl extensions/&<T: copy> for [T]/& {
1179
1179
is returned. If `f` matches no elements then none is returned.
1180
1180
" ]
1181
1181
#[ inline]
1182
- fn find ( f : fn ( T ) -> bool ) -> option < T > { find ( self , f) }
1182
+ pure fn find ( f : fn ( T ) -> bool ) -> option < T > { find ( self , f) }
1183
1183
#[ doc = "
1184
1184
Search for the last element that matches a given predicate
1185
1185
@@ -1188,7 +1188,7 @@ impl extensions/&<T: copy> for [T]/& {
1188
1188
matches no elements then none is returned.
1189
1189
" ]
1190
1190
#[ inline]
1191
- fn rfind ( f : fn ( T ) -> bool ) -> option < T > { rfind ( self , f) }
1191
+ pure fn rfind ( f : fn ( T ) -> bool ) -> option < T > { rfind ( self , f) }
1192
1192
}
1193
1193
1194
1194
#[ doc = "Unsafe operations" ]
0 commit comments