• H
    syntax: make #[deriving(TotalOrd)] lazy. · 8407ec9f
    Huon Wilson 提交于
    Previously it would call:
    
      f(sf1.cmp(&of1), f(sf2.cmp(&of2), ...))
    
    (where s/of1 = 'self/other field 1', and f was
    std::cmp::lexical_ordering)
    
    This meant that every .cmp subcall got evaluated when calling a derived
    TotalOrd.cmp.
    
    This corrects this to use
    
       let test = sf1.cmp(&of1);
       if test == Equal {
          let test = sf2.cmp(&of2);
          if test == Equal {
            // ...
          } else {
            test
          }
       } else {
         test
       }
    
    This gives a lexical ordering by short-circuiting on the first comparison
    that is not Equal.
    8407ec9f
totalord.rs 3.7 KB