about summary refs log tree commit diff
path: root/src/libcore/cmp.rs
AgeCommit message (Collapse)AuthorLines
2016-05-23Complete `PartialOrd`'s example so it passes make check-docsCarol (Nichols || Goulding)-0/+21
2016-05-23Prefer `ClassName` over `Self` in example trait implementationsCarol (Nichols || Goulding)-8/+8
2016-05-23Use `()` when referring to functionsCarol (Nichols || Goulding)-4/+4
2016-05-23Add some newlines in some code examplesCarol (Nichols || Goulding)-0/+2
2016-05-23"non equal" => "not equal"; consistent with the surrounding textCarol (Nichols || Goulding)-1/+1
2016-05-23Add an explicit "How can I implement `PartialOrd`" doc sectionCarol (Nichols || Goulding)-2/+44
Similar to the `Ord` examples but calling out that it can be defined using `cmp` from `Ord` or using `partial_cmp` in a situation that demands that.
2016-05-23Add an explicit "How can I implement `Ord`" doc sectionCarol (Nichols || Goulding)-0/+40
References: - http://stackoverflow.com/q/29884402/51683 - http://stackoverflow.com/q/28387711/51683
2016-05-23Add an explicit "How can I implement `Eq`" doc sectionCarol (Nichols || Goulding)-1/+24
Building on the example in PartialEq.
2016-05-23Add an explicit "How can I implement `PartialEq`"? doc sectionCarol (Nichols || Goulding)-4/+31
Including an example of a custom implementation. I put this expanded section after the `Derivable` section to encourage use of that first.
2016-05-23`derive` explanation for PartialOrd should match that for OrdCarol (Nichols || Goulding)-2/+2
I think these just got out of sync, but both use a lexicographic ordering. Relevant commits in the history of these explanations: * 8b81f76 on 2015-06-30 * e22770b on 2016-02-09
2016-05-23Add explanations about what derived trait implementations doCarol (Nichols || Goulding)-2/+7
2016-04-15Implement `Default` for more types in the standard libraryTobias Bucher-1/+1
Also add `Hash` to `std::cmp::Ordering` and most possible traits to `fmt::Error`.
2016-03-18Add doc examplesGuillaume Gomez-0/+35
2016-02-09Clarifying behavior of #[derive(Ord, PartialOrd)] in doc comments.Adam Perry-4/+4
Removing redundant statement about lexicographic ordering.
2016-01-21Remove `unsafe` code from `core::cmp`Andrea Canciani-13/+4
Instead of transmuting, use a match; the compiler has learnt how to optimize it.
2015-11-16Make note about traits that can be derivedSteve Klabnik-0/+8
in their API docs Fixes #29711
2015-11-12libcore: deny warnings in doctestsKevin Butler-4/+0
2015-11-06Remove stability annotations from trait impl itemsVadim Petrochenkov-2/+0
Remove `stable` stability annotations from inherent impls
2015-09-30Clarify logic instead of using 'vice versa'Steve Klabnik-1/+1
Fixes #28166
2015-09-16Reuse cmp in totally ordered typesAndrea Canciani-3/+1
Instead of manually defining it, `partial_cmp` can simply wrap the result of `cmp` for totally ordered types.
2015-09-16Specialize `PartialOrd` for totally ordered primitive typesAndrea Canciani-4/+22
Knowing the result of equality comparison can enable additional optimizations in LLVM. Additionally, this makes it obvious that `partial_cmp` on totally ordered types cannot return `None`.
2015-08-12Remove all unstable deprecated functionalityAlex Crichton-73/+1
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-08-09Replace many uses of `mem::transmute` with more specific functionsTobias Bucher-1/+6
The replacements are functions that usually use a single `mem::transmute` in their body and restrict input and output via more concrete types than `T` and `U`. Worth noting are the `transmute` functions for slices and the `from_utf8*` family for mutable slices. Additionally, `mem::transmute` was often used for casting raw pointers, when you can already cast raw pointers just fine with `as`.
2015-07-29Rollup merge of #27326 - steveklabnik:doc_show_use, r=GankroSteve Klabnik-4/+8
In spirit with https://internals.rust-lang.org/t/should-we-keep-including-obvious-imports-in-code-examples/2217, show the feature flags we're using in examples. (also one instance of 'use')
2015-07-27std: Deprecate a number of unstable featuresAlex Crichton-0/+2
Many of these have long since reached their stage of being obsolete, so this commit starts the removal process for all of them. The unstable features that were deprecated are: * cmp_partial * fs_time * hash_default * int_slice * iter_min_max * iter_reset_fuse * iter_to_vec * map_in_place * move_from * owned_ascii_ext * page_size * read_and_zero * scan_state * slice_chars * slice_position_elem * subslice_offset
2015-07-27Show appropriate feature flags in docsSteve Klabnik-4/+8
2015-06-30Make note of Ord's derive orderingSteve Klabnik-0/+2
Fixes #26620
2015-06-17Fallout in tests and docs from feature renamingsAlex Crichton-4/+4
2015-06-17core: Split apart the global `core` featureAlex Crichton-18/+20
This commit shards the broad `core` feature of the libcore library into finer grained features. This split groups together similar APIs and enables tracking each API separately, giving a better sense of where each feature is within the stabilization process. A few minor APIs were deprecated along the way: * Iterator::reverse_in_place * marker::NoCopy
2015-05-09Convert #[lang="..."] to #[lang = "..."]Nick Hamann-2/+2
In my opinion this looks nicer, but also it matches the whitespace generally used for stability markers more closely.
2015-04-20remove bad example from PartialEq docsSteve Klabnik-21/+0
Fixes #24173
2015-03-31rollup merge of #23288: alexcrichton/issue-19470Alex Crichton-1/+0
This is a deprecated attribute that is slated for removal, and it also affects all implementors of the trait. This commit removes the attribute and fixes up implementors accordingly. The primary implementation which was lost was the ability to compare `&[T]` and `Vec<T>` (in that order). This change also modifies the `assert_eq!` macro to not consider both directions of equality, only the one given in the left/right forms to the macro. This modification is motivated due to the fact that `&[T] == Vec<T>` no longer compiles, causing hundreds of errors in unit tests in the standard library (and likely throughout the community as well). Closes #19470 [breaking-change]
2015-03-31rollup merge of #23878: Ryman/stable_extremesAlex Crichton-5/+9
`min`-like functions now return the leftmost element/input for equal elements. `max`-like return the rightmost. Closes #23687. cc @HeroesGrave, @aturon, @alexcrichton
2015-03-31std: Remove #[old_orphan_check] from PartialEqAlex Crichton-1/+0
This is a deprecated attribute that is slated for removal, and it also affects all implementors of the trait. This commit removes the attribute and fixes up implementors accordingly. The primary implementation which was lost was the ability to compare `&[T]` and `Vec<T>` (in that order). This change also modifies the `assert_eq!` macro to not consider both directions of equality, only the one given in the left/right forms to the macro. This modification is motivated due to the fact that `&[T] == Vec<T>` no longer compiles, causing hundreds of errors in unit tests in the standard library (and likely throughout the community as well). cc #19470 [breaking-change]
2015-03-31Stabilize std::numAaron Turon-2/+0
This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping<X>` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change]
2015-03-30libcore: Ensure min and max functions are consistent for equal inputsKevin Butler-5/+9
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-1/+6
2015-02-18Audit `core::cmp` for `int/uint`.Felix S. Klock II-6/+6
* cast 3-valued `core::cmp::Ordering` to `i32`, not `int`. * use `isize`/`usize` in the impl macros.
2015-02-17Test fixes and rebase conflictsAlex Crichton-4/+5
2015-02-13Improve core::cmp docsSteve Klabnik-66/+206
2015-01-29s/Show/Debug/gJorge Aparicio-1/+1
2015-01-25Merge remote-tracking branch 'rust-lang/master'Brian Anderson-8/+8
Conflicts: src/libcore/cmp.rs src/libcore/fmt/mod.rs src/libcore/iter.rs src/libcore/marker.rs src/libcore/num/f32.rs src/libcore/num/f64.rs src/libcore/result.rs src/libcore/str/mod.rs src/librustc/lint/builtin.rs src/librustc/lint/context.rs src/libstd/sync/mpsc/mod.rs src/libstd/sync/poison.rs
2015-01-25Moving away from deprecated i/u suffixes in libcoreAlfie John-8/+8
2015-01-23grandfathered -> rust1Brian Anderson-44/+44
2015-01-23Set unstable feature names appropriatelyBrian Anderson-2/+2
* `core` - for the core crate * `hash` - hashing * `io` - io * `path` - path * `alloc` - alloc crate * `rand` - rand crate * `collections` - collections crate * `std_misc` - other parts of std * `test` - test crate * `rustc_private` - everything else
2015-01-21Remove 'since' from unstable attributesBrian Anderson-2/+2
2015-01-21Add 'feature' and 'since' to stability attributesBrian Anderson-46/+46
2015-01-08Improvements to feature stagingBrian Anderson-2/+2
This gets rid of the 'experimental' level, removes the non-staged_api case (i.e. stability levels for out-of-tree crates), and lets the staged_api attributes use 'unstable' and 'deprecated' lints. This makes the transition period to the full feature staging design a bit nicer.
2015-01-07markers -> markerNick Cameron-2/+2
2015-01-07Change `std::kinds` to `std::markers`; flatten `std::kinds::marker`Nick Cameron-2/+2
[breaking-change]