about summary refs log tree commit diff
path: root/src/libcore/cmp.rs
AgeCommit message (Collapse)AuthorLines
2020-04-29Fix doc link to Eq trait from PartialEq traitNicholas Bishop-0/+1
The `Eq` link was incorrectly going to the `eq` method of `PartialEq` instead of to the `Eq` trait.
2020-04-16Dogfood or_patterns in the standard libraryJosh Stone-2/+2
2020-04-03Replace float module consts with assoc consts in documentationLinus Färnstrand-1/+1
2020-02-08Mark several functions and methods in core::cmp as #[must_use]Michael Bradshaw-0/+13
2020-01-30Add missing links for cmp traitsGuillaume Gomez-20/+31
2020-01-08Use matches macro in libcore and libstdIgor Aleksanov-16/+4
2019-12-30Less-than is asymmetric, not antisymmetricJP Sugarbroad-2/+2
This has bothered me for a while. It's such a small nit, but...
2019-12-22Format the worldMark Rousskov-50/+140
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-1/+1
2019-12-14Revert "Stabilize the `never_type`, written `!`."Niko Matsakis-4/+4
This reverts commit 15c30ddd69d6cc3fffe6d304c6dc968a5ed046f1.
2019-12-11Rollup merge of #66881 - ↵Mazdak Farrokhzad-1/+11
krishna-veerareddy:issue-66780-bool-ord-optimization, r=sfackler Optimize Ord trait implementation for bool Casting the booleans to `i8`s and converting their difference into `Ordering` generates better assembly than casting them to `u8`s and comparing them. Fixes #66780 #### Comparison([Godbolt link](https://rust.godbolt.org/z/PjBpvF)) ##### Old assembly: ```asm example::boolean_cmp: mov ecx, edi xor ecx, esi test esi, esi mov eax, 255 cmove eax, ecx test edi, edi cmovne eax, ecx ret ``` ##### New assembly: ```asm example::boolean_cmp: mov eax, edi sub al, sil ret ``` ##### Old LLVM-MCA statistics: ``` Iterations: 100 Instructions: 800 Total Cycles: 234 Total uOps: 1000 Dispatch Width: 6 uOps Per Cycle: 4.27 IPC: 3.42 Block RThroughput: 1.7 ``` ##### New LLVM-MCA statistics: ``` Iterations: 100 Instructions: 300 Total Cycles: 110 Total uOps: 500 Dispatch Width: 6 uOps Per Cycle: 4.55 IPC: 2.73 Block RThroughput: 1.0 ```
2019-12-10Add better documentation for unsafe blockKrishna Sai Veera Reddy-1/+1
2019-12-02Document usage of unsafe blockKrishna Sai Veera Reddy-0/+1
2019-12-01Remove ord lang itemcad97-1/+0
2019-11-29Optimize Ord trait implementation for boolKrishna Sai Veera Reddy-1/+10
Casting the booleans to `i8`s and converting their difference into `Ordering` generates better assembly than casting them to `u8`s and comparing them.
2019-11-26follow the same function order in the traitGuanqun Lu-6/+6
This removes several warnings in IDE.
2019-11-22Rollup merge of #66566 - robamler:issue-66476, r=rkruppeMazdak Farrokhzad-14/+18
Document pitfall with `impl PartialEq<B> for A` Fixes #66476 by turning the violating example into an explicit counterexample.
2019-11-21Document pitfall with `impl PartialEq<B> for A`Robert Bamler-14/+18
Fixes #66476 by turning the violating example into an explicit counterexample.
2019-11-21Stabilize the `never_type`, written `!`.Mazdak Farrokhzad-4/+4
2019-10-25Migrate from `#[structural_match]` attribute a lang-item trait.Felix S. Klock II-2/+2
(Or more precisely, a pair of such traits: one for `derive(PartialEq)` and one for `derive(Eq)`.) ((The addition of the second marker trait, `StructuralEq`, is largely a hack to work-around `fn (&T)` not implementing `PartialEq` and `Eq`; see also issue rust-lang/rust#46989; otherwise I would just check if `Eq` is implemented.)) Note: this does not use trait fulfillment error-reporting machinery; it just uses the trait system to determine if the ADT was tagged or not. (Nonetheless, I have kept an `on_unimplemented` message on the new trait for structural_match check, even though it is currently not used.) Note also: this does *not* resolve the ICE from rust-lang/rust#65466, as noted in a comment added in this commit. Further work is necessary to resolve that and other problems with the structural match checking, especially to do so without breaking stable code (adapted from test fn-ptr-is-structurally-matchable.rs): ```rust fn r_sm_to(_: &SM) {} fn main() { const CFN6: Wrap<fn(&SM)> = Wrap(r_sm_to); let input: Wrap<fn(&SM)> = Wrap(r_sm_to); match Wrap(input) { Wrap(CFN6) => {} Wrap(_) => {} }; } ``` where we would hit a problem with the strategy of unconditionally checking for `PartialEq` because the type `for <'a> fn(&'a SM)` does not currently even *implement* `PartialEq`. ---- added review feedback: * use an or-pattern * eschew `return` when tail position will do. * don't need fresh_expansion; just add `structural_match` to appropriate `allow_internal_unstable` attributes. also fixed example in doc comment so that it actually compiles.
2019-09-25Snap cfgs to new betaMark Rousskov-4/+0
2019-09-23Move `--cfg bootstrap` out of `rustc.rs`Alex Crichton-4/+4
Instead let's do this via `RUSTFLAGS` in `builder.rs`. Currently requires a submodule update of `stdarch` to fix a problem with previous compilers.
2019-09-14Add cmp::{min_by, min_by_key, max_by, max_by_key}Tim Vermeulen-2/+88
2019-09-04Fix doc links in `std::cmp` moduleLzu Tao-6/+14
These links are rendered in `core::cmp` but not in `std::cmp`.
2019-08-29Small improvement for Ord implementation of integersLzu Tao-2/+2
2019-08-21Add comment to avoid accidentally remove the changes.Lzu Tao-0/+2
2019-08-21Use more optimal Ord implementation for integersLzu Tao-3/+3
2019-08-17Make built-in derives opaque macrosMatthew Jasper-4/+4
2019-08-14Handle cfg(bootstrap) throughoutMark Rousskov-4/+0
2019-08-10Give built-in macros stable addresses in the standard libraryVadim Petrochenkov-0/+32
2019-07-26Remove redundant `mut` from variable declaration.Tomasz Różański-1/+1
2019-04-18libcore => 2018Taiki Endo-2/+2
2019-04-09Remove strange formatting in `Ordering` docs.Eric Huss-3/+3
2019-03-25Clarify `{Ord,f32,f64}::clamp` docs a littleTobias Bucher-4/+9
Explicitly call out when it returns NaN, adhere to the panic doc guidelines.
2019-03-18Replaced self-reflective explicit types with clearer `Self` or `Self::…` ↵Vincent Esche-7/+7
in stdlib docs
2019-03-15Auto merge of #58710 - EdorianDark:master, r=sfacklerbors-0/+26
Add clamp for ranges. Implements #44095 Ready for merge
2019-03-09Use lifetime contravariance to elide more lifetimes in core+alloc+stdScott McMurray-24/+24
2019-03-09Revert "Revert "Add clamp functions""Dirk Leifeld-0/+26
2019-02-10tests: doc commentsAlexander Regueiro-1/+1
2019-01-18Rollup merge of #57357 - frewsxcv:frewsxcv-partial-eq, r=QuietMisdreavusMazdak Farrokhzad-16/+22
Cleanup PartialEq docs. - Cleanup the `impl PartialEq<BookFormat> for Book` implementation - Implement `impl PartialEq<Book> for BookFormat` so it’s symmetric - Fixes https://github.com/rust-lang/rust/issues/53844. - Removes the last example since it appears to be redundant with the previous two examples.
2019-01-15demonstrate symmetryCorey Farwell-1/+1
2019-01-12whitespaceCorey Farwell-6/+6
2019-01-12bring back the example i removed, also add symmetry and simplify implCorey Farwell-0/+42
2019-01-12add comment explaining what the derive doesCorey Farwell-0/+1
2019-01-11re-do docs for core::cmpSteve Klabnik-20/+15
Fixes #32934
2019-01-06Update cmp.rsCorey Farwell-1/+1
2019-01-06add missing derive to fix compile errorCorey Farwell-0/+1
2019-01-05Fix compile errorCorey Farwell-1/+1
2019-01-05Cleanup PartialEq docs.Corey Farwell-47/+9
- Cleanup the `impl PartialEq<BookFormat> for Book` implementation - Implement `impl PartialEq<Book> for BookFormat` so it’s symmetric - Fixes https://github.com/rust-lang/rust/issues/53844. - Removes the last example since it appears to be redundant with the previous two examples.
2018-12-29Specify criterion for PartialOrdCzipperz-2/+3