Ascii char equality with primitive types
This commit is contained in:
parent
be8e477ecc
commit
c974074a64
@ -25,4 +25,73 @@ impl PartialEq<Self> for AsciiChar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl PartialEq<u8> for AsciiChar {
|
||||||
|
fn eq(&self, other: &u8) -> bool {
|
||||||
|
match self {
|
||||||
|
AsciiChar::NOT_ASCII => return false,
|
||||||
|
AsciiChar::ASCII(c1) => return c1 == other,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq<AsciiChar> for u8 {
|
||||||
|
fn eq(&self, other: &AsciiChar) -> bool {
|
||||||
|
match other {
|
||||||
|
AsciiChar::NOT_ASCII => return false,
|
||||||
|
AsciiChar::ASCII(c2) => return self == c2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq<char> for AsciiChar {
|
||||||
|
fn eq(&self, other: &char) -> bool {
|
||||||
|
match self {
|
||||||
|
AsciiChar::NOT_ASCII => return false,
|
||||||
|
AsciiChar::ASCII(c1) => return (*c1 as u32) == (*other as u32),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq<AsciiChar> for char {
|
||||||
|
fn eq(&self, other: &AsciiChar) -> bool {
|
||||||
|
match other {
|
||||||
|
AsciiChar::NOT_ASCII => return false,
|
||||||
|
AsciiChar::ASCII(c2) => return (*self as u32) == (*c2 as u32),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl PartialEq<u16> for AsciiChar {
|
||||||
|
fn eq(&self, other: &u16) -> bool {
|
||||||
|
match self {
|
||||||
|
AsciiChar::NOT_ASCII => return false,
|
||||||
|
AsciiChar::ASCII(c1) => return (*c1 as u32) == (*other as u32),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq<AsciiChar> for u16 {
|
||||||
|
fn eq(&self, other: &AsciiChar) -> bool {
|
||||||
|
match other {
|
||||||
|
AsciiChar::NOT_ASCII => return false,
|
||||||
|
AsciiChar::ASCII(c2) => return (*self as u32) == (*c2 as u32),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq<u32> for AsciiChar {
|
||||||
|
fn eq(&self, other: &u32) -> bool {
|
||||||
|
match self {
|
||||||
|
AsciiChar::NOT_ASCII => return false,
|
||||||
|
AsciiChar::ASCII(c1) => return (*c1 as u32) == *other,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq<AsciiChar> for u32 {
|
||||||
|
fn eq(&self, other: &AsciiChar) -> bool {
|
||||||
|
match other {
|
||||||
|
AsciiChar::NOT_ASCII => return false,
|
||||||
|
AsciiChar::ASCII(c2) => return *self == (*c2 as u32),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user