]> git.lizzy.rs Git - rust.git/commitdiff
derive Hash for ranges
authorAlex Burka <durka42+github@gmail.com>
Thu, 9 Jun 2016 14:52:36 +0000 (10:52 -0400)
committerAlex Burka <durka42+github@gmail.com>
Thu, 9 Jun 2016 14:52:36 +0000 (10:52 -0400)
Fixes #34170.

src/libcore/ops.rs

index 50c4dc697c2062f7de9c2f9e3661cc228749c27d..39f27bd47ba4c1adede37ebaa7c76c8c3c318abc 100644 (file)
@@ -1475,7 +1475,7 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
 ///     assert_eq!(arr[1..3], [  1,2  ]);
 /// }
 /// ```
-#[derive(Copy, Clone, PartialEq, Eq)]
+#[derive(Copy, Clone, PartialEq, Eq, Hash)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct RangeFull;
 
@@ -1506,7 +1506,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 ///     assert_eq!(arr[1..3], [  1,2  ]);  // Range
 /// }
 /// ```
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, PartialEq, Eq, Hash)]  // not Copy -- see #27186
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct Range<Idx> {
     /// The lower bound of the range (inclusive).
@@ -1570,7 +1570,7 @@ pub fn contains(&self, item: Idx) -> bool {
 ///     assert_eq!(arr[1..3], [  1,2  ]);
 /// }
 /// ```
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, PartialEq, Eq, Hash)]  // not Copy -- see #27186
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct RangeFrom<Idx> {
     /// The lower bound of the range (inclusive).
@@ -1619,7 +1619,7 @@ pub fn contains(&self, item: Idx) -> bool {
 ///     assert_eq!(arr[1..3], [  1,2  ]);
 /// }
 /// ```
-#[derive(Copy, Clone, PartialEq, Eq)]
+#[derive(Copy, Clone, PartialEq, Eq, Hash)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct RangeTo<Idx> {
     /// The upper bound of the range (exclusive).
@@ -1774,7 +1774,7 @@ pub fn contains(&self, item: Idx) -> bool {
 ///     assert_eq!(arr[1...2], [  1,2  ]);
 /// }
 /// ```
-#[derive(Copy, Clone, PartialEq, Eq)]
+#[derive(Copy, Clone, PartialEq, Eq, Hash)]
 #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
 pub struct RangeToInclusive<Idx> {
     /// The upper bound of the range (inclusive)