File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -1095,6 +1095,32 @@ impl From<&CStr> for CString {
1095
1095
}
1096
1096
}
1097
1097
1098
+ #[ stable( feature = "c_string_eq_c_str" , since = "CURRENT_RUSTC_VERSION" ) ]
1099
+ impl PartialEq < CStr > for CString {
1100
+ #[ inline]
1101
+ fn eq ( & self , other : & CStr ) -> bool {
1102
+ * * self == * other
1103
+ }
1104
+
1105
+ #[ inline]
1106
+ fn ne ( & self , other : & CStr ) -> bool {
1107
+ * * self != * other
1108
+ }
1109
+ }
1110
+
1111
+ #[ stable( feature = "c_string_eq_c_str" , since = "CURRENT_RUSTC_VERSION" ) ]
1112
+ impl PartialEq < & CStr > for CString {
1113
+ #[ inline]
1114
+ fn eq ( & self , other : & & CStr ) -> bool {
1115
+ * * self == * * other
1116
+ }
1117
+
1118
+ #[ inline]
1119
+ fn ne ( & self , other : & & CStr ) -> bool {
1120
+ * * self != * * other
1121
+ }
1122
+ }
1123
+
1098
1124
#[ stable( feature = "cstring_asref" , since = "1.7.0" ) ]
1099
1125
impl ops:: Index < ops:: RangeFull > for CString {
1100
1126
type Output = CStr ;
@@ -1178,6 +1204,19 @@ impl CStr {
1178
1204
}
1179
1205
}
1180
1206
1207
+ #[ stable( feature = "c_string_eq_c_str" , since = "CURRENT_RUSTC_VERSION" ) ]
1208
+ impl PartialEq < CString > for CStr {
1209
+ #[ inline]
1210
+ fn eq ( & self , other : & CString ) -> bool {
1211
+ * self == * * other
1212
+ }
1213
+
1214
+ #[ inline]
1215
+ fn ne ( & self , other : & CString ) -> bool {
1216
+ * self != * * other
1217
+ }
1218
+ }
1219
+
1181
1220
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1182
1221
impl core:: error:: Error for NulError {
1183
1222
#[ allow( deprecated) ]
Original file line number Diff line number Diff line change @@ -660,6 +660,19 @@ impl CStr {
660
660
}
661
661
}
662
662
663
+ #[ stable( feature = "c_string_eq_c_str" , since = "CURRENT_RUSTC_VERSION" ) ]
664
+ impl PartialEq < & Self > for CStr {
665
+ #[ inline]
666
+ fn eq ( & self , other : & & Self ) -> bool {
667
+ * self == * * other
668
+ }
669
+
670
+ #[ inline]
671
+ fn ne ( & self , other : & & Self ) -> bool {
672
+ * self != * * other
673
+ }
674
+ }
675
+
663
676
// `.to_bytes()` representations are compared instead of the inner `[c_char]`s,
664
677
// because `c_char` is `i8` (not `u8`) on some platforms.
665
678
// That is why this is implemented manually and not derived.
@@ -670,6 +683,7 @@ impl PartialOrd for CStr {
670
683
self . to_bytes ( ) . partial_cmp ( & other. to_bytes ( ) )
671
684
}
672
685
}
686
+
673
687
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
674
688
impl Ord for CStr {
675
689
#[ inline]
You can’t perform that action at this time.
0 commit comments