]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #8400 : blake2-ppc/rust/seq-ord, r=cmr
authorbors <bors@rust-lang.org>
Mon, 12 Aug 2013 18:53:18 +0000 (11:53 -0700)
committerbors <bors@rust-lang.org>
Mon, 12 Aug 2013 18:53:18 +0000 (11:53 -0700)
Use Eq + Ord for lexicographical ordering of sequences.

For each of <, <=, >= or > as R, use::

    [x, ..xs] R [y, ..ys]  =  if x != y { x R y } else { xs R ys }

Previous code using `a < b` and then `!(b < a)` for short-circuiting
fails on cases such as  [1.0, 2.0] < [0.0/0.0, 3.0], where the first
element was effectively considered equal.

Containers like &[T] did also implement only one comparison operator `<`,
and derived the comparison results from this. This isn't correct either for
Ord.

Implement functions in `std::iterator::order::{lt,le,gt,ge,equal,cmp}` that all
iterable containers can use for lexical order.

We also visit tuple ordering, having the same problem and same solution
(but differing implementation).

1  2 
src/libextra/dlist.rs
src/libstd/iterator.rs
src/libstd/option.rs
src/libstd/prelude.rs
src/libstd/tuple.rs
src/libstd/vec.rs

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index d626b8604db87ed065ee36ff93d632514edbc7a8,e088fd9a647dd084e6daed30e8c2a78ad176fd8a..2228922d9e4d951b9dcec6660649183eb711b3f8
@@@ -561,12 -561,12 +561,12 @@@ impl<'self, T> RandomAccessIterator<&'s
  
  #[cfg(not(test))]
  pub mod traits {
 -    use super::Vector;
 +    use super::*;
  
      use clone::Clone;
-     use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Equal, Equiv};
+     use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Equiv};
+     use iterator::order;
      use ops::Add;
-     use option::{Some, None};
  
      impl<'self,T:Eq> Eq for &'self [T] {
          fn eq(&self, other: & &'self [T]) -> bool {