about summary refs log tree commit diff
path: root/src/libstd/cmp.rs
AgeCommit message (Collapse)AuthorLines
2014-05-07core: Inherit the cmp moduleAlex Crichton-296/+0
This removes the TotalOrd and TotalEq implementation macros, they will be added later to the numeric modules (where the other comparison implementations live).
2014-04-21Fix misspellings in comments.Joseph Crail-2/+2
2014-04-06Remove use of block comments in src/libstd/cmp.rsTobias Bucher-84/+72
2014-04-06Add requirements of TotalEq and TotalOrdTobias Bucher-2/+23
Clarify that TotalEq needs an underlying equivalence relation and that TotalOrd needs a total ordering and specifically named the required (and sufficient) attributes.
2014-04-04[std::cmp] add missing docs and provide an exampleKevin Cantu-17/+91
2014-03-29auto merge of #13188 : FlaPer87/rust/master, r=alexcrichtonbors-10/+0
2014-03-29Register new snapshotFlavio Percoco-10/+0
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-1/+1
Closes #2569
2014-03-23std: remove the `equals` method from `TotalEq`.Huon Wilson-16/+17
`TotalEq` is now just an assertion about the `Eq` impl of a type (i.e. `==` is a total equality if a type implements `TotalEq`) so the extra method is just confusing. Also, a new method magically appeared as a hack to allow deriving to assert that the contents of a struct/enum are also TotalEq, because the deriving infrastructure makes it very hard to do anything but create a trait method. (You didn't hear about this horrible work-around from me :(.)
2014-03-15Remove std::cmp::cmp2.Steven Fackler-20/+0
It isn't used anywhere and `cmp2(a, b, c, d)` is identical to `(a, b).cmp(&(c, d))`.
2014-03-14cmp: switch `min` and `max` to `TotalOrd`Daniel Micay-2/+2
The `Float` trait provides correct `min` and `max` methods on floating point types, providing a consistent result regardless of the order the parameters are passed. These generic functions do not take the necessary performance hit to correctly support a partial order, so the true requirement should be given as a type bound. Closes #12712
2014-03-07create a sensible comparison trait hierarchyDaniel Micay-6/+8
* `Ord` inherits from `Eq` * `TotalOrd` inherits from `TotalEq` * `TotalOrd` inherits from `Ord` * `TotalEq` inherits from `Eq` This is a partial implementation of #12517.
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-1/+1
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-13Removed num::OrderableMichael Darakananda-0/+2
2014-01-09Remove ApproxEq and assert_approx_eq!Brendan Zabarauskas-7/+0
This trait seems to stray too far from the mandate of a standard library as implementations may vary between use cases.
2013-08-30Now inline default 'ne' methodsEric Martin-0/+2
2013-08-09Remove redundant Ord method impls.OGINO Masanori-6/+3
Basically, generic containers should not use the default methods since a type of elements may not guarantees total order. str could use them since u8's Ord guarantees total order. Floating point numbers are also broken with the default methods because of NaN. Thanks for @thestinger. Timespec also guarantees total order AIUI. I'm unsure whether extra::semver::Identifier does so I left it alone. Proof needed. Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-04syntax: make #[deriving(TotalOrd)] lazy.Huon Wilson-1/+0
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.
2013-08-03remove obsolete `foreach` keywordDaniel Micay-1/+1
this has been replaced by `for`
2013-08-03make `for` parse as `foreach` doesDaniel Micay-1/+3
Closes #6997
2013-07-25auto merge of #8030 : thestinger/rust/iterator, r=huonwbors-1/+0
2013-07-24rm default method lintDaniel Micay-1/+0
default methods are enabled by default, so there's not much point in keeping around a lint to report them as being experimental
2013-07-23Fix some impls such that all supertraits are actually implemented.Michael Sullivan-0/+6
2013-07-15cmp: Use default methods in trait Eq, require only Eq::eqblake2-ppc-2/+4
2013-07-13cmp: Use default methods in trait Ord, only require Ord::ltblake2-ppc-8/+9
It will be simpler to implement only one method for Ord, while we also allow implementing all four Ord methods for semantics or performance reasons. We only supply three default methods (and not four), because don't have any nice error reporting for the case where at least one method must be implemented, but it's arbitrary which.
2013-06-18replace #[inline(always)] with #[inline]. r=burningtree.Graydon Hoare-10/+10
2013-06-09cmp: remove duplicate free functionsDaniel Micay-30/+0
2013-05-30Require documentation by default for libstdAlex Crichton-0/+2
Adds documentation for various things that I understand. Adds #[allow(missing_doc)] for lots of things that I don't understand.
2013-05-22libstd: Rename libcore to libstd and libstd to libextra; update makefiles.Patrick Walton-0/+265
This only changes the directory names; it does not change the "real" metadata names.
2013-05-06Move FuzzyEq trait into core::cmp and rename it to 'ApproxEq'Brendan Zabarauskas-102/+0
2013-05-02mod items need to be marked with `cfg(test)` not `test`.Felix S. Klock II-1/+1
2013-03-29librustc: Remove `fail_unless!`Patrick Walton-10/+10
2013-03-22librustc: Remove the `const` declaration form everywherePatrick Walton-1/+1
2013-03-22libstd: Remove all uses of `pure` from libstd. rs=depurePatrick Walton-10/+10
2013-03-07librustc: Convert all uses of `assert` over to `fail_unless!`Patrick Walton-10/+10
2013-02-14librustc: Replace `impl Type : Trait` with `impl Trait for Type`. ↵Patrick Walton-4/+4
rs=implflipping
2013-02-07auto merge of #4831 : bjz/rust/incoming, r=pcwaltonbors-9/+46
This is useful for comparing more complex types that include floats.
2013-02-07Make ~fn non-copyable, make &fn copyable, split barefn/closure types,Niko Matsakis-1/+0
correct handling of moves for struct-record update. Part of #3678. Fixes #2828, #3904, #4719.
2013-02-07Add type parameter for epsilon valueBrendan Zabarauskas-5/+42
2013-02-07Convert fuzzy_epsilon constant to upper case and make publicBrendan Zabarauskas-4/+4
2013-01-30librustc: Change `self` as a type to `Self` everywhere. r=brsonPatrick Walton-2/+2
2013-01-30rustc: make integral type inference transactional, close #3211, close #4401, ↵Graydon Hoare-3/+3
close #3398.
2013-01-29Merge pull request #4676 from thestinger/fuzzyTim Chevalier-3/+3
fix FuzzyEq
2013-01-29fix FuzzyEqDaniel Micay-3/+3
2013-01-29Fix licenseck to allow 2012-2013 as the year rangeTim Chevalier-2/+2
2013-01-29implement fuzzy_eq with fuzzy_eq_epsDaniel Micay-4/+4
2013-01-28add a FuzzyEq method that accepts an epsilon valueDaniel Micay-1/+20
2013-01-28update FuzzyEq to explicit selfDaniel Micay-11/+10
2013-01-28fix std::cmp docstringDaniel Micay-1/+1
2012-12-27librustc: Terminate name searches at the nearest module scope for paths that ↵Patrick Walton-0/+4
contain at least two components. r=graydon