@@ -175,21 +175,14 @@ where
175
175
S : Data < Elem = A > ,
176
176
D : Dimension ,
177
177
{
178
- /// Finds the elementwise minimum of the array.
179
- ///
180
- /// **Panics** if the array is empty.
181
- fn min ( & self ) -> & A
182
- where
183
- A : Ord ;
184
-
185
178
/// Finds the elementwise minimum of the array.
186
179
///
187
180
/// Returns `None` if any of the pairwise orderings tested by the function
188
181
/// are undefined. (For example, this occurs if there are any
189
182
/// floating-point NaN values in the array.)
190
183
///
191
184
/// Additionally, returns `None` if the array is empty.
192
- fn min_partialord ( & self ) -> Option < & A >
185
+ fn min ( & self ) -> Option < & A >
193
186
where
194
187
A : PartialOrd ;
195
188
@@ -203,21 +196,14 @@ where
203
196
A : MaybeNan ,
204
197
A :: NotNan : Ord ;
205
198
206
- /// Finds the elementwise maximum of the array.
207
- ///
208
- /// **Panics** if the array is empty.
209
- fn max ( & self ) -> & A
210
- where
211
- A : Ord ;
212
-
213
199
/// Finds the elementwise maximum of the array.
214
200
///
215
201
/// Returns `None` if any of the pairwise orderings tested by the function
216
202
/// are undefined. (For example, this occurs if there are any
217
203
/// floating-point NaN values in the array.)
218
204
///
219
205
/// Additionally, returns `None` if the array is empty.
220
- fn max_partialord ( & self ) -> Option < & A >
206
+ fn max ( & self ) -> Option < & A >
221
207
where
222
208
A : PartialOrd ;
223
209
@@ -285,22 +271,11 @@ where
285
271
S : Data < Elem = A > ,
286
272
D : Dimension ,
287
273
{
288
- fn min ( & self ) -> & A
289
- where
290
- A : Ord ,
291
- {
292
- let first = self
293
- . iter ( )
294
- . next ( )
295
- . expect ( "Attempted to find min of empty array." ) ;
296
- self . fold ( first, |acc, elem| if elem < acc { elem } else { acc } )
297
- }
298
-
299
- fn min_partialord ( & self ) -> Option < & A >
274
+ fn min ( & self ) -> Option < & A >
300
275
where
301
276
A : PartialOrd ,
302
277
{
303
- let first = self . iter ( ) . next ( ) ?;
278
+ let first = self . first ( ) ?;
304
279
self . fold ( Some ( first) , |acc, elem| match elem. partial_cmp ( acc?) ? {
305
280
cmp:: Ordering :: Less => Some ( elem) ,
306
281
_ => acc,
@@ -312,7 +287,7 @@ where
312
287
A : MaybeNan ,
313
288
A :: NotNan : Ord ,
314
289
{
315
- let first = self . iter ( ) . next ( ) . and_then ( |v| v. try_as_not_nan ( ) ) ;
290
+ let first = self . first ( ) . and_then ( |v| v. try_as_not_nan ( ) ) ;
316
291
A :: from_not_nan_ref_opt ( self . fold_skipnan ( first, |acc, elem| {
317
292
Some ( match acc {
318
293
Some ( acc) => acc. min ( elem) ,
@@ -321,22 +296,11 @@ where
321
296
} ) )
322
297
}
323
298
324
- fn max ( & self ) -> & A
325
- where
326
- A : Ord ,
327
- {
328
- let first = self
329
- . iter ( )
330
- . next ( )
331
- . expect ( "Attempted to find max of empty array." ) ;
332
- self . fold ( first, |acc, elem| if elem > acc { elem } else { acc } )
333
- }
334
-
335
- fn max_partialord ( & self ) -> Option < & A >
299
+ fn max ( & self ) -> Option < & A >
336
300
where
337
301
A : PartialOrd ,
338
302
{
339
- let first = self . iter ( ) . next ( ) ?;
303
+ let first = self . first ( ) ?;
340
304
self . fold ( Some ( first) , |acc, elem| match elem. partial_cmp ( acc?) ? {
341
305
cmp:: Ordering :: Greater => Some ( elem) ,
342
306
_ => acc,
@@ -348,7 +312,7 @@ where
348
312
A : MaybeNan ,
349
313
A :: NotNan : Ord ,
350
314
{
351
- let first = self . iter ( ) . next ( ) . and_then ( |v| v. try_as_not_nan ( ) ) ;
315
+ let first = self . first ( ) . and_then ( |v| v. try_as_not_nan ( ) ) ;
352
316
A :: from_not_nan_ref_opt ( self . fold_skipnan ( first, |acc, elem| {
353
317
Some ( match acc {
354
318
Some ( acc) => acc. max ( elem) ,
0 commit comments