2 #![allow(unused, clippy::redundant_clone, clippy::derive_partial_eq_without_eq)] // See #5700
4 // Define the types in each module to avoid trait impls leaking between modules.
5 macro_rules! impl_types {
12 impl ToOwned for Borrowed {
14 fn to_owned(&self) -> Owned {
19 impl std::borrow::Borrow<Borrowed> for Owned {
20 fn borrow(&self) -> &Borrowed {
21 static VALUE: Borrowed = Borrowed {};
28 // Only Borrowed == Owned is implemented
29 mod borrowed_eq_owned {
32 impl PartialEq<Owned> for Borrowed {
33 fn eq(&self, _: &Owned) -> bool {
40 let borrowed = Borrowed {};
42 if borrowed == owned {}
43 if borrowed == owned {}
47 // Only Owned == Borrowed is implemented
48 mod owned_eq_borrowed {
51 impl PartialEq<Borrowed> for Owned {
52 fn eq(&self, _: &Borrowed) -> bool {
59 let borrowed = Borrowed {};
61 if owned == borrowed {}
62 if owned == borrowed {}
69 // NOTE: PartialEq<Borrowed> for T can't be implemented due to the orphan rules
70 impl<T> PartialEq<T> for Borrowed
72 T: AsRef<str> + ?Sized,
74 fn eq(&self, _: &T) -> bool {
79 impl std::fmt::Display for Borrowed {
80 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
86 let borrowed = Borrowed {};
88 if borrowed == "Hi" {}
89 if borrowed == "Hi" {}