1use crate::{GString, Validator};
2
3impl<V: Validator + Eq, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Ord
4 for GString<V, MIN, MAX, ASCII_ONLY>
5{
6 fn cmp(&self, other: &Self) -> core::cmp::Ordering {
7 self.as_str().cmp(other.as_str())
8 }
9}
10
11impl<
12 LHSV: Validator,
13 RHSV: Validator,
14 const LMIN: usize,
15 const LMAX: usize,
16 const LASCII: bool,
17 const RMIN: usize,
18 const RMAX: usize,
19 const RASCII: bool,
20> PartialOrd<GString<RHSV, RMIN, RMAX, RASCII>> for GString<LHSV, LMIN, LMAX, LASCII>
21{
22 fn partial_cmp(
23 &self,
24 other: &GString<RHSV, RMIN, RMAX, RASCII>,
25 ) -> Option<core::cmp::Ordering> {
26 Some(self.as_str().cmp(other.as_str()))
27 }
28}
29
30impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialOrd<str>
31 for GString<V, MIN, MAX, ASCII_ONLY>
32{
33 fn partial_cmp(&self, other: &str) -> Option<core::cmp::Ordering> {
34 Some(self.as_str().cmp(other))
35 }
36}
37
38impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialOrd<&str>
39 for GString<V, MIN, MAX, ASCII_ONLY>
40{
41 fn partial_cmp(&self, other: &&str) -> Option<core::cmp::Ordering> {
42 Some(self.as_str().cmp(*other))
43 }
44}
45
46impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool>
47 PartialOrd<GString<V, MIN, MAX, ASCII_ONLY>> for str
48{
49 fn partial_cmp(&self, other: &GString<V, MIN, MAX, ASCII_ONLY>) -> Option<core::cmp::Ordering> {
50 Some(self.cmp(other.as_str()))
51 }
52}
53
54impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool>
55 PartialOrd<GString<V, MIN, MAX, ASCII_ONLY>> for &str
56{
57 fn partial_cmp(&self, other: &GString<V, MIN, MAX, ASCII_ONLY>) -> Option<core::cmp::Ordering> {
58 Some((*self).cmp(other.as_str()))
59 }
60}
61
62#[cfg(feature = "alloc")]
63impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialOrd<String>
64 for GString<V, MIN, MAX, ASCII_ONLY>
65{
66 fn partial_cmp(&self, other: &String) -> Option<core::cmp::Ordering> {
67 Some(self.as_str().cmp(other.as_str()))
68 }
69}
70
71#[cfg(feature = "alloc")]
72impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool>
73 PartialOrd<GString<V, MIN, MAX, ASCII_ONLY>> for String
74{
75 fn partial_cmp(&self, other: &GString<V, MIN, MAX, ASCII_ONLY>) -> Option<core::cmp::Ordering> {
76 Some(self.as_str().cmp(other.as_str()))
77 }
78}