Rollup merge of #137268 - bjoernager:c-string-eq-c-str, r=Amanieu · rust-lang/rust@30550c0 (original) (raw)
`@@ -1099,6 +1099,46 @@ impl From<&CStr> for CString {
`
1099
1099
`}
`
1100
1100
`}
`
1101
1101
``
``
1102
`+
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
`
``
1103
`+
impl PartialEq for CString {
`
``
1104
`+
#[inline]
`
``
1105
`+
fn eq(&self, other: &CStr) -> bool {
`
``
1106
`+
**self == *other
`
``
1107
`+
}
`
``
1108
+
``
1109
`+
#[inline]
`
``
1110
`+
fn ne(&self, other: &CStr) -> bool {
`
``
1111
`+
**self != *other
`
``
1112
`+
}
`
``
1113
`+
}
`
``
1114
+
``
1115
`+
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
`
``
1116
`+
impl PartialEq<&CStr> for CString {
`
``
1117
`+
#[inline]
`
``
1118
`+
fn eq(&self, other: &&CStr) -> bool {
`
``
1119
`+
**self == **other
`
``
1120
`+
}
`
``
1121
+
``
1122
`+
#[inline]
`
``
1123
`+
fn ne(&self, other: &&CStr) -> bool {
`
``
1124
`+
**self != **other
`
``
1125
`+
}
`
``
1126
`+
}
`
``
1127
+
``
1128
`+
#[cfg(not(no_global_oom_handling))]
`
``
1129
`+
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
`
``
1130
`+
impl PartialEq<Cow<'_, CStr>> for CString {
`
``
1131
`+
#[inline]
`
``
1132
`+
fn eq(&self, other: &Cow<'_, CStr>) -> bool {
`
``
1133
`+
**self == **other
`
``
1134
`+
}
`
``
1135
+
``
1136
`+
#[inline]
`
``
1137
`+
fn ne(&self, other: &Cow<'_, CStr>) -> bool {
`
``
1138
`+
**self != **other
`
``
1139
`+
}
`
``
1140
`+
}
`
``
1141
+
1102
1142
`#[stable(feature = "cstring_asref", since = "1.7.0")]
`
1103
1143
`impl ops::Indexops::RangeFull for CString {
`
1104
1144
`type Output = CStr;
`
`@@ -1181,6 +1221,75 @@ impl CStr {
`
1181
1221
`}
`
1182
1222
`}
`
1183
1223
``
``
1224
`+
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
`
``
1225
`+
impl PartialEq for CStr {
`
``
1226
`+
#[inline]
`
``
1227
`+
fn eq(&self, other: &CString) -> bool {
`
``
1228
`+
*self == **other
`
``
1229
`+
}
`
``
1230
+
``
1231
`+
#[inline]
`
``
1232
`+
fn ne(&self, other: &CString) -> bool {
`
``
1233
`+
*self != **other
`
``
1234
`+
}
`
``
1235
`+
}
`
``
1236
+
``
1237
`+
#[cfg(not(no_global_oom_handling))]
`
``
1238
`+
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
`
``
1239
`+
impl PartialEq<Cow<'_, Self>> for CStr {
`
``
1240
`+
#[inline]
`
``
1241
`+
fn eq(&self, other: &Cow<'_, Self>) -> bool {
`
``
1242
`+
*self == **other
`
``
1243
`+
}
`
``
1244
+
``
1245
`+
#[inline]
`
``
1246
`+
fn ne(&self, other: &Cow<'_, Self>) -> bool {
`
``
1247
`+
*self != **other
`
``
1248
`+
}
`
``
1249
`+
}
`
``
1250
+
``
1251
`+
#[cfg(not(no_global_oom_handling))]
`
``
1252
`+
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
`
``
1253
`+
impl PartialEq for Cow<'_, CStr> {
`
``
1254
`+
#[inline]
`
``
1255
`+
fn eq(&self, other: &CStr) -> bool {
`
``
1256
`+
**self == *other
`
``
1257
`+
}
`
``
1258
+
``
1259
`+
#[inline]
`
``
1260
`+
fn ne(&self, other: &CStr) -> bool {
`
``
1261
`+
**self != *other
`
``
1262
`+
}
`
``
1263
`+
}
`
``
1264
+
``
1265
`+
#[cfg(not(no_global_oom_handling))]
`
``
1266
`+
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
`
``
1267
`+
impl PartialEq<&CStr> for Cow<'_, CStr> {
`
``
1268
`+
#[inline]
`
``
1269
`+
fn eq(&self, other: &&CStr) -> bool {
`
``
1270
`+
**self == **other
`
``
1271
`+
}
`
``
1272
+
``
1273
`+
#[inline]
`
``
1274
`+
fn ne(&self, other: &&CStr) -> bool {
`
``
1275
`+
**self != **other
`
``
1276
`+
}
`
``
1277
`+
}
`
``
1278
+
``
1279
`+
#[cfg(not(no_global_oom_handling))]
`
``
1280
`+
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
`
``
1281
`+
impl PartialEq for Cow<'_, CStr> {
`
``
1282
`+
#[inline]
`
``
1283
`+
fn eq(&self, other: &CString) -> bool {
`
``
1284
`+
**self == **other
`
``
1285
`+
}
`
``
1286
+
``
1287
`+
#[inline]
`
``
1288
`+
fn ne(&self, other: &CString) -> bool {
`
``
1289
`+
**self != **other
`
``
1290
`+
}
`
``
1291
`+
}
`
``
1292
+
1184
1293
`#[stable(feature = "rust1", since = "1.0.0")]
`
1185
1294
`impl core::error::Error for NulError {
`
1186
1295
`#[allow(deprecated)]
`