1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use core::cmp::Ordering;
use core::hash::{Hash, Hasher};
#[derive(Debug, Copy, Clone, Eq)]
pub struct UnicodeBlock {
pub(crate) name: &'static str,
pub(crate) start: u32,
pub(crate) end: u32,
}
impl UnicodeBlock {
#[inline]
pub const fn name(&self) -> &'static str {
self.name
}
#[inline]
pub const fn start(&self) -> u32 {
self.start
}
#[inline]
pub const fn end(&self) -> u32 {
self.end
}
}
impl UnicodeBlock {
#[inline]
pub fn contains(&self, c: char) -> bool {
let u = c as u32;
u >= self.start && u <= self.end
}
}
impl PartialEq for UnicodeBlock {
#[inline]
fn eq(&self, other: &UnicodeBlock) -> bool {
self.start.eq(&other.start)
}
}
impl PartialOrd for UnicodeBlock {
#[inline]
fn partial_cmp(&self, other: &UnicodeBlock) -> Option<Ordering> {
self.start.partial_cmp(&other.start)
}
}
impl Ord for UnicodeBlock {
#[inline]
fn cmp(&self, other: &UnicodeBlock) -> Ordering {
self.start.cmp(&other.start)
}
}
impl Hash for UnicodeBlock {
#[inline]
fn hash<H: Hasher>(&self, state: &mut H) {
self.start.hash(state)
}
}