@@ -1287,12 +1287,46 @@ impl<T: ?Sized> Drop for Weak<T> {
12871287 }
12881288}
12891289
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+
12901321#[ stable( feature = "rust1" , since = "1.0.0" ) ]
12911322impl < T : ?Sized + PartialEq > PartialEq for Arc < T > {
12921323 /// Equality for two `Arc`s.
12931324 ///
12941325 /// Two `Arc`s are equal if their inner values are equal.
12951326 ///
1327+ /// If `T` also implements `Eq`, two `Arc`s that point to the same value are
1328+ /// always equal.
1329+ ///
12961330 /// # Examples
12971331 ///
12981332 /// ```
@@ -1302,14 +1336,18 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
13021336 ///
13031337 /// assert!(five == Arc::new(5));
13041338 /// ```
1339+ #[ inline]
13051340 fn eq ( & self , other : & Arc < T > ) -> bool {
1306- * ( * self ) == * ( * other)
1341+ ArcEqIdent :: eq ( self , other)
13071342 }
13081343
13091344 /// Inequality for two `Arc`s.
13101345 ///
13111346 /// Two `Arc`s are unequal if their inner values are unequal.
13121347 ///
1348+ /// If `T` also implements `Eq`, two `Arc`s that point to the same value are
1349+ /// never unequal.
1350+ ///
13131351 /// # Examples
13141352 ///
13151353 /// ```
@@ -1319,10 +1357,12 @@ impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
13191357 ///
13201358 /// assert!(five != Arc::new(6));
13211359 /// ```
1360+ #[ inline]
13221361 fn ne ( & self , other : & Arc < T > ) -> bool {
1323- * ( * self ) != * ( * other)
1362+ ArcEqIdent :: ne ( self , other)
13241363 }
13251364}
1365+
13261366#[ stable( feature = "rust1" , since = "1.0.0" ) ]
13271367impl < T : ?Sized + PartialOrd > PartialOrd for Arc < T > {
13281368 /// Partial comparison for two `Arc`s.
0 commit comments