@@ -1287,12 +1287,46 @@ impl<T: ?Sized> Drop for Weak<T> {
1287
1287
}
1288
1288
}
1289
1289
1290
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1291
+ trait ArcEqIdent < T : ?Sized + PartialEq > {
1292
+ fn eq ( & self , other : & Arc < T > ) -> bool ;
1293
+ fn ne ( & self , other : & Arc < T > ) -> bool ;
1294
+ }
1295
+
1296
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1297
+ impl < T : ?Sized + PartialEq > ArcEqIdent < T > for Arc < T > {
1298
+ #[ inline]
1299
+ default fn eq ( & self , other : & Arc < T > ) -> bool {
1300
+ * * self == * * other
1301
+ }
1302
+ #[ inline]
1303
+ default fn ne ( & self , other : & Arc < T > ) -> bool {
1304
+ * * self != * * other
1305
+ }
1306
+ }
1307
+
1308
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1309
+ impl < T : ?Sized + Eq > ArcEqIdent < T > for Arc < T > {
1310
+ #[ inline]
1311
+ fn eq ( & self , other : & Arc < T > ) -> bool {
1312
+ Arc :: ptr_eq ( self , other) || * * self == * * other
1313
+ }
1314
+
1315
+ #[ inline]
1316
+ fn ne ( & self , other : & Arc < T > ) -> bool {
1317
+ !Arc :: ptr_eq ( self , other) && * * self != * * other
1318
+ }
1319
+ }
1320
+
1290
1321
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1291
1322
impl < T : ?Sized + PartialEq > PartialEq for Arc < T > {
1292
1323
/// Equality for two `Arc`s.
1293
1324
///
1294
1325
/// Two `Arc`s are equal if their inner values are equal.
1295
1326
///
1327
+ /// If `T` also implements `Eq`, two `Arc`s that point to the same value are
1328
+ /// always equal.
1329
+ ///
1296
1330
/// # Examples
1297
1331
///
1298
1332
/// ```
@@ -1302,14 +1336,18 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
1302
1336
///
1303
1337
/// assert!(five == Arc::new(5));
1304
1338
/// ```
1339
+ #[ inline]
1305
1340
fn eq ( & self , other : & Arc < T > ) -> bool {
1306
- * ( * self ) == * ( * other)
1341
+ ArcEqIdent :: eq ( self , other)
1307
1342
}
1308
1343
1309
1344
/// Inequality for two `Arc`s.
1310
1345
///
1311
1346
/// Two `Arc`s are unequal if their inner values are unequal.
1312
1347
///
1348
+ /// If `T` also implements `Eq`, two `Arc`s that point to the same value are
1349
+ /// never unequal.
1350
+ ///
1313
1351
/// # Examples
1314
1352
///
1315
1353
/// ```
@@ -1319,10 +1357,12 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
1319
1357
///
1320
1358
/// assert!(five != Arc::new(6));
1321
1359
/// ```
1360
+ #[ inline]
1322
1361
fn ne ( & self , other : & Arc < T > ) -> bool {
1323
- * ( * self ) != * ( * other)
1362
+ ArcEqIdent :: ne ( self , other)
1324
1363
}
1325
1364
}
1365
+
1326
1366
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1327
1367
impl < T : ?Sized + PartialOrd > PartialOrd for Arc < T > {
1328
1368
/// Partial comparison for two `Arc`s.
0 commit comments