Skip to main content

g_string/
equality.rs

1use crate::{GString, Validator};
2
3impl<
4    LHSV: Validator,
5    RHSV: Validator,
6    const LMIN: usize,
7    const LMAX: usize,
8    const LASCII: bool,
9    const RMIN: usize,
10    const RMAX: usize,
11    const RASCII: bool,
12> PartialEq<GString<RHSV, RMIN, RMAX, RASCII>> for GString<LHSV, LMIN, LMAX, LASCII>
13{
14    fn eq(&self, other: &GString<RHSV, RMIN, RMAX, RASCII>) -> bool {
15        self.as_str() == other.as_str()
16    }
17}
18
19impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialEq<str>
20    for GString<V, MIN, MAX, ASCII_ONLY>
21{
22    fn eq(&self, other: &str) -> bool {
23        self.as_str() == other
24    }
25}
26
27impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialEq<&str>
28    for GString<V, MIN, MAX, ASCII_ONLY>
29{
30    fn eq(&self, other: &&str) -> bool {
31        self.as_str() == *other
32    }
33}
34
35impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool>
36    PartialEq<GString<V, MIN, MAX, ASCII_ONLY>> for str
37{
38    fn eq(&self, other: &GString<V, MIN, MAX, ASCII_ONLY>) -> bool {
39        self == other.as_str()
40    }
41}
42
43impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool>
44    PartialEq<GString<V, MIN, MAX, ASCII_ONLY>> for &str
45{
46    fn eq(&self, other: &GString<V, MIN, MAX, ASCII_ONLY>) -> bool {
47        *self == other.as_str()
48    }
49}
50
51impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialEq<String>
52    for GString<V, MIN, MAX, ASCII_ONLY>
53{
54    fn eq(&self, other: &String) -> bool {
55        self == other.as_str()
56    }
57}
58
59impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool>
60    PartialEq<GString<V, MIN, MAX, ASCII_ONLY>> for String
61{
62    fn eq(&self, other: &GString<V, MIN, MAX, ASCII_ONLY>) -> bool {
63        self == other.as_str()
64    }
65}