Skip to content

Commit 85e76e8

Browse files
committed
derive Hash for ranges
Fixes #34170.
1 parent 33c8992 commit 85e76e8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libcore/ops.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
14751475
/// assert_eq!(arr[1..3], [ 1,2 ]);
14761476
/// }
14771477
/// ```
1478-
#[derive(Copy, Clone, PartialEq, Eq)]
1478+
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
14791479
#[stable(feature = "rust1", since = "1.0.0")]
14801480
pub struct RangeFull;
14811481

@@ -1506,7 +1506,7 @@ impl fmt::Debug for RangeFull {
15061506
/// assert_eq!(arr[1..3], [ 1,2 ]); // Range
15071507
/// }
15081508
/// ```
1509-
#[derive(Clone, PartialEq, Eq)]
1509+
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
15101510
#[stable(feature = "rust1", since = "1.0.0")]
15111511
pub struct Range<Idx> {
15121512
/// The lower bound of the range (inclusive).
@@ -1570,7 +1570,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
15701570
/// assert_eq!(arr[1..3], [ 1,2 ]);
15711571
/// }
15721572
/// ```
1573-
#[derive(Clone, PartialEq, Eq)]
1573+
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
15741574
#[stable(feature = "rust1", since = "1.0.0")]
15751575
pub struct RangeFrom<Idx> {
15761576
/// The lower bound of the range (inclusive).
@@ -1619,7 +1619,7 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
16191619
/// assert_eq!(arr[1..3], [ 1,2 ]);
16201620
/// }
16211621
/// ```
1622-
#[derive(Copy, Clone, PartialEq, Eq)]
1622+
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
16231623
#[stable(feature = "rust1", since = "1.0.0")]
16241624
pub struct RangeTo<Idx> {
16251625
/// The upper bound of the range (exclusive).
@@ -1774,7 +1774,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
17741774
/// assert_eq!(arr[1...2], [ 1,2 ]);
17751775
/// }
17761776
/// ```
1777-
#[derive(Copy, Clone, PartialEq, Eq)]
1777+
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
17781778
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
17791779
pub struct RangeToInclusive<Idx> {
17801780
/// The upper bound of the range (inclusive)

0 commit comments

Comments
 (0)