smol_bytes/utf8_bytes_mut/
cmp.rs1use super::*;
2
3impl PartialEq for Utf8BytesMut {
4 fn eq(&self, other: &Self) -> bool {
5 self.as_str() == other.as_str()
6 }
7}
8
9impl Eq for Utf8BytesMut {}
10
11impl PartialOrd for Utf8BytesMut {
12 fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
13 Some(self.cmp(other))
14 }
15}
16
17impl Ord for Utf8BytesMut {
18 fn cmp(&self, other: &Self) -> core::cmp::Ordering {
19 self.as_str().cmp(other.as_str())
20 }
21}
22
23impl PartialEq<str> for Utf8BytesMut {
24 fn eq(&self, other: &str) -> bool {
25 self.as_str() == other
26 }
27}
28
29impl PartialEq<Utf8BytesMut> for str {
30 fn eq(&self, other: &Utf8BytesMut) -> bool {
31 self == other.as_str()
32 }
33}
34
35impl PartialEq<&str> for Utf8BytesMut {
36 fn eq(&self, other: &&str) -> bool {
37 self.as_str() == *other
38 }
39}
40
41impl PartialEq<Utf8BytesMut> for &str {
42 fn eq(&self, other: &Utf8BytesMut) -> bool {
43 *self == other.as_str()
44 }
45}
46
47impl PartialOrd<str> for Utf8BytesMut {
48 fn partial_cmp(&self, other: &str) -> Option<core::cmp::Ordering> {
49 self.as_str().partial_cmp(other)
50 }
51}
52
53impl PartialOrd<Utf8BytesMut> for str {
54 fn partial_cmp(&self, other: &Utf8BytesMut) -> Option<core::cmp::Ordering> {
55 self.partial_cmp(other.as_str())
56 }
57}
58
59impl core::hash::Hash for Utf8BytesMut {
60 fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
61 self.as_str().hash(state);
62 }
63}
64
65#[cfg(any(feature = "std", feature = "alloc"))]
66const _: () = {
67 use std::string::String;
68
69 impl PartialEq<String> for Utf8BytesMut {
70 fn eq(&self, other: &String) -> bool {
71 self.as_str() == other.as_str()
72 }
73 }
74
75 impl PartialEq<Utf8BytesMut> for String {
76 fn eq(&self, other: &Utf8BytesMut) -> bool {
77 self.as_str() == other.as_str()
78 }
79 }
80
81 impl PartialOrd<String> for Utf8BytesMut {
82 fn partial_cmp(&self, other: &String) -> Option<core::cmp::Ordering> {
83 self.as_str().partial_cmp(other.as_str())
84 }
85 }
86
87 impl PartialOrd<Utf8BytesMut> for String {
88 fn partial_cmp(&self, other: &Utf8BytesMut) -> Option<core::cmp::Ordering> {
89 self.as_str().partial_cmp(other.as_str())
90 }
91 }
92};