diff options
| author | Stjepan Glavina <stjepang@gmail.com> | 2017-05-27 17:00:11 +0200 |
|---|---|---|
| committer | Stjepan Glavina <stjepang@gmail.com> | 2017-05-27 17:15:32 +0200 |
| commit | f5421367a2d72d5da415d2bbf97538099ff3ade0 (patch) | |
| tree | c226dc98d38063c18e3f65e91c87e95fde06b1dd /src/libcollections | |
| parent | 0aeb9c12979e6da753701a798d04105b6b1a8c28 (diff) | |
Docs: impls of PartialEq/PartialOrd/Ord must agree
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/binary_heap.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index a5a2f70492d..0094804631b 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -42,8 +42,11 @@ //! // instead of a max-heap. //! impl Ord for State { //! fn cmp(&self, other: &State) -> Ordering { -//! // Notice that the we flip the ordering here +//! // Notice that the we flip the ordering on costs. +//! // In case of a tie we compare positions - this step is necessary +//! // to make implementations of `PartialEq` and `Ord` consistent. //! other.cost.cmp(&self.cost) +//! .then_with(|| self.position.cmp(&other.position)) //! } //! } //! |
