about summary refs log tree commit diff
path: root/src/libcore/cmp.rs
AgeCommit message (Collapse)AuthorLines
2014-07-18core: Stabliize core::cmpBrian Anderson-0/+31
Mark Eq, PartialEq, Ord, PartialOrd as unstable: they will change slightly after trait reform. Equiv as experimental: better solutions are desired. min/max stable.
2014-07-06Register snapshot.Luqman Aden-15/+0
2014-06-29Implement RFC#28: Add PartialOrd::partial_cmpSteven Fackler-9/+72
I ended up altering the semantics of Json's PartialOrd implementation. It used to be the case that Null < Null, but I can't think of any reason for an ordering other than the default one so I just switched it over to using the derived implementation. This also fixes broken `PartialOrd` implementations for `Vec` and `TreeMap`. RFC: 0028-partial-cmp
2014-06-29Extract tests from libcore to a separate crateSteven Fackler-64/+0
Libcore's test infrastructure is complicated by the fact that many lang items are defined in the crate. The current approach (realcore/realstd imports) is hacky and hard to work with (tests inside of core::cmp haven't been run for months!). Moving tests to a separate crate does mean that they can only test the public API of libcore, but I don't feel that that is too much of an issue. The only tests that I had to get rid of were some checking the various numeric formatters, but those are also exercised through normal format! calls in other tests.
2014-06-29librustc: Remove the fallback to `int` for integers and `f64` forPatrick Walton-3/+3
floating point numbers for real. This will break code that looks like: let mut x = 0; while ... { x += 1; } println!("{}", x); Change that code to: let mut x = 0i; while ... { x += 1; } println!("{}", x); Closes #15201. [breaking-change]
2014-06-11rustc: Update how Gc<T> is recognizedAlex Crichton-23/+0
This commit uses the same trick as ~/Box to map Gc<T> to @T internally inside the compiler. This moves a number of implementations of traits to the `gc` module in the standard library. This removes functions such as `Gc::new`, `Gc::borrow`, and `Gc::ptr_eq` in favor of the more modern equivalents, `box(GC)`, `Deref`, and pointer equality. The Gc pointer itself should be much more useful now, and subsequent commits will move the compiler away from @T towards Gc<T> [breaking-change]
2014-06-07Clarify restrictions on neSteven Fackler-2/+4
I can't think of any sane cases where this restriction would not hold, and the standard library seems to assume it pretty much everywhere.
2014-06-07Fix PartialEq documentation with regards to floatsSteven Fackler-9/+9
It is in fact the case that `NaN != NaN`. The true relations for compareQuietNotEqual are LT, GT *and* UN. I also rephrased the docs for PartialOrd since floats are not the only types which are not totally ordered.
2014-06-01std: Drop Total from Total{Eq,Ord}Alex Crichton-22/+19
This completes the last stage of the renaming of the comparison hierarchy of traits. This change renames TotalEq to Eq and TotalOrd to Ord. In the future the new Eq/Ord will be filled out with their appropriate methods, but for now this change is purely a renaming change. [breaking-change]
2014-05-30syntax: Prepare for Total{Eq,Ord} => {Eq,Ord}Alex Crichton-0/+3
This commit adds the groundwork for the renaming of the Total{Eq,Ord} traits. After this commit hits a snapshot, the traits can be renamed.
2014-05-30std: Rename {Eq,Ord} to Partial{Eq,Ord}Alex Crichton-33/+31
This is part of the ongoing renaming of the equality traits. See #12517 for more details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord} or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}. cc #12517 [breaking-change]
2014-05-29auto merge of #14492 : alexcrichton/rust/totaleq, r=pnkfelixbors-0/+3
This is a transitionary step towards completing #12517. This change modifies the compiler to accept Partial{Ord,Eq} as deriving modes which will currently expand to implementations of PartialOrd and PartialEq (synonyms for Eq/Ord). After a snapshot, all of deriving(Eq, Ord) will be removed, and after a snapshot of that, TotalEq/TotalOrd will be renamed to Eq/Ord.
2014-05-28rustc: Accept PartialOrd/PartialOrdEq for Eq/OrdAlex Crichton-0/+3
This is a transitionary step towards completing #12517. This change modifies the compiler to accept Partial{Ord,Eq} as deriving modes which will currently expand to implementations of PartialOrd and PartialEq (synonyms for Eq/Ord). After a snapshot, all of deriving(Eq, Ord) will be removed, and after a snapshot of that, TotalEq/TotalOrd will be renamed to Eq/Ord.
2014-05-28Move trait impls for primitives near trait definitionPiotr Jawniak-3/+71
Closes #12925
2014-05-24core: rename strbuf::StrBuf to string::StringRicho Healey-1/+1
[breaking-change]
2014-05-22libcore: Remove all uses of `~str` from `libcore`.Patrick Walton-1/+1
[breaking-change]
2014-05-15core: Derive Show impls wherever possibleAlex Crichton-1/+1
These were temporarily moved to explicit implementations, but now that fmt is in core it's possible to derive again.
2014-05-15core: Remove the unit moduleBrian Anderson-1/+17
2014-05-14auto merge of #14133 : db48x/rust/ord-for-mut-refs, r=alexcrichtonbors-1/+33
Also Show, which is useful in assertions. Fixes #14074
2014-05-14define Eq,TotalEq,Ord,TotalOrd for &mut TDaniel Brooks-1/+33
Also Show, which is useful in assertions. Fixes #14074
2014-05-13std: Move the owned module from core to stdAlex Crichton-24/+0
The compiler was updated to recognize that implementations for ty_uniq(..) are allowed if the Box lang item is located in the current crate. This enforces the idea that libcore cannot allocated, and moves all related trait implementations from libcore to libstd. This is a breaking change in that the AnyOwnExt trait has moved from the any module to the owned module. Any previous users of std::any::AnyOwnExt should now use std::owned::AnyOwnExt instead. This was done because the trait is intended for Box traits and only Box traits. [breaking-change]
2014-05-07Test fixes and rebase conflictsAlex Crichton-12/+13
2014-05-07core: Inhert ~/@/& cmp traits, remove old modulesAlex Crichton-0/+75
This commit removes the std::{managed, reference} modules. The modules serve essentially no purpose, and the only free function removed was `managed::ptr_eq` which can be achieved by comparing references. [breaking-change]
2014-05-07core: Inherit the cmp moduleAlex Crichton-0/+244
This removes the TotalOrd and TotalEq implementation macros, they will be added later to the numeric modules (where the other comparison implementations live).
2013-05-22libstd: Rename libcore to libstd and libstd to libextra; update makefiles.Patrick Walton-265/+0
This only changes the directory names; it does not change the "real" metadata names.
2013-05-18Convert various inner doc-comments to outer doc-commentsBrendan Zabarauskas-2/+1
2013-05-06Move FuzzyEq trait into core::cmp and rename it to 'ApproxEq'Brendan Zabarauskas-0/+7
2013-04-25implement Ord, TotalEq and TotalOrd for charDaniel Micay-0/+4
Closes #6063
2013-04-12auto merge of #5827 : ↵bors-0/+21
nikomatsakis/rust/issue-5656-change-meaning-of-borrowed-self, r=pcwalton See #5656 for details. r? @pcwalton
2013-04-12libcore: combine cmp::Ordering instances in lexical order.Huon Wilson-0/+27
2013-04-10Reason about nested free variables that appear in a functionNiko Matsakis-0/+21
signature. In a nutshell, the idea is to (1) report an error if, for a region pointer `'a T`, the lifetime `'a` is longer than any lifetimes that appear in `T` (in other words, if a borrowed pointer outlives any portion of its contents) and then (2) use this to assume that in a function like `fn(self: &'a &'b T)`, the relationship `'a <= 'b` holds. This is needed for #5656. Fixes #5728.
2013-04-07cmp: add Ord+TotalOrd impls for Ordering itselfDaniel Micay-1/+25
2013-04-07cmp: derive Clone for OrderingDaniel Micay-1/+1
2013-03-29librustc: Remove `fail_unless!`Patrick Walton-2/+2
2013-03-27add a TotalEq traitDaniel Micay-11/+44
2013-03-27cmp: rm TotalOrd impl code duplicationDaniel Micay-53/+22
2013-03-22libcore: Remove `pure` from libcore. rs=depurePatrick Walton-27/+27
2013-03-22core: replace uses of old deriving attribute with new oneAndrew Paseltiner-1/+1
2013-03-20change some uses of fail_unless to assert_eqJohn Clements-5/+5
2013-03-07librustc: Convert all uses of `assert` over to `fail_unless!`Patrick Walton-5/+5
2013-03-05libcore: Implement an `Equiv` trait and use it on hashmaps.Patrick Walton-0/+8
7.3x speedup in string map search speed on a microbenchmark of pure hashmap searching against a constant string, due to the lack of allocations. I ran into a few snags. 1. The way the coherence check is set up, I can't implement `Equiv<@str>` and `Equiv<~str>` for `&str` simultaneously. 2. I wanted to implement `Equiv<T>` for all `T:Eq` (i.e. every type can be compared to itself if it implements `Eq`), but the coherence check didn't like that either. 3. I couldn't add this to the `Map` trait because `LinearMap` needs special handling for its `Q` type parameter: it must not only implement `Equiv<T>` but also `Hash` and `Eq`. 4. `find_equiv(&&"foo")` doesn't parse, because of the double ampersand. It has to be written `find_equiv(& &"foo")`. We can probably just fix this. Nevertheless, this is a huge win; it should address a major source of performance problems, including the one here: http://maniagnosis.crsr.net/2013/02/creating-letterpress-cheating-program.html
2013-03-02inline the implementation of TotalOrd for integersDaniel Micay-0/+1
2013-03-02add a TotalOrd traitDaniel Micay-0/+76
2013-02-20librustc: Separate most trait bounds with '+'. rs=plussingPatrick Walton-8/+8
2013-02-13core: add min and max to cmp, re-export various places.Graydon Hoare-0/+9
2013-02-07Make ~fn non-copyable, make &fn copyable, split barefn/closure types,Niko Matsakis-4/+0
correct handling of moves for struct-record update. Part of #3678. Fixes #2828, #3904, #4719.
2013-01-30librustc: Change `self` as a type to `Self` everywhere. r=brsonPatrick Walton-6/+6
2013-01-13core: Align cmp::le() with the other implementationsPeter Williams-4/+10
Also add comments reminding that IEEE 754 requires unusual semantics for comparison operators as applied to NaNs (x != x, if x = NaN), in case someone in the future wants to get clever.
2013-01-14Inlining methods/functions in core.gifnksm-0/+6
Also inlining some functions which take functions as arguments.
2012-12-03Update license, add license boilerplate to most files. Remainder will follow.Graydon Hoare-0/+10