@@ -94,7 +94,7 @@ use crate::str; |
|
|
94 |
94 |
/// ``` |
95 |
95 |
/// |
96 |
96 |
/// [str]: prim@str "str" |
97 |
|
-#[derive(Hash)] |
|
97 |
+#[derive(PartialEq, Eq, Hash)] |
98 |
98 |
#[stable(feature = "core_c_str", since = "1.64.0")] |
99 |
99 |
#[rustc_has_incoherent_inherent_impls] |
100 |
100 |
#[lang = "CStr"] |
@@ -104,7 +104,6 @@ use crate::str; |
|
|
104 |
104 |
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under |
105 |
105 |
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy. |
106 |
106 |
#[repr(transparent)] |
107 |
|
-#[allow(clippy::derived_hash_with_manual_eq)] |
108 |
107 |
pub struct CStr { |
109 |
108 |
// FIXME: this should not be represented with a DST slice but rather with |
110 |
109 |
// just a raw `c_char` along with some form of marker to make |
@@ -678,15 +677,9 @@ impl CStr { |
|
|
678 |
677 |
} |
679 |
678 |
} |
680 |
679 |
|
681 |
|
-#[stable(feature = "rust1", since = "1.0.0")] |
682 |
|
-impl PartialEq for CStr { |
683 |
|
-#[inline] |
684 |
|
-fn eq(&self, other: &CStr) -> bool { |
685 |
|
-self.to_bytes().eq(other.to_bytes()) |
686 |
|
-} |
687 |
|
-} |
688 |
|
-#[stable(feature = "rust1", since = "1.0.0")] |
689 |
|
-impl Eq for CStr {} |
|
680 |
+// `.to_bytes()` representations are compared instead of the inner `[c_char]`s, |
|
681 |
+// because `c_char` is `i8` (not `u8`) on some platforms. |
|
682 |
+// That is why this is implemented manually and not derived. |
690 |
683 |
#[stable(feature = "rust1", since = "1.0.0")] |
691 |
684 |
impl PartialOrd for CStr { |
692 |
685 |
#[inline] |