diff --git a/src/ascii/char.rs b/src/ascii/char.rs index 886abad..03e7bcd 100644 --- a/src/ascii/char.rs +++ b/src/ascii/char.rs @@ -25,4 +25,73 @@ impl PartialEq for AsciiChar { } } } +impl PartialEq for AsciiChar { + fn eq(&self, other: &u8) -> bool { + match self { + AsciiChar::NOT_ASCII => return false, + AsciiChar::ASCII(c1) => return c1 == other, + } + } +} +impl PartialEq for u8 { + fn eq(&self, other: &AsciiChar) -> bool { + match other { + AsciiChar::NOT_ASCII => return false, + AsciiChar::ASCII(c2) => return self == c2, + } + } +} + +impl PartialEq 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 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 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 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 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 for u32 { + fn eq(&self, other: &AsciiChar) -> bool { + match other { + AsciiChar::NOT_ASCII => return false, + AsciiChar::ASCII(c2) => return *self == (*c2 as u32), + } + } +}