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
|
pub struct Icon {
pub path: &'static str,
pub content: &'static str,
}
macro_rules! icons_consts {
($i:ident => $p:expr) => {
pub const $i: Icon = Icon {
path: $p,
content: include_str!(concat!("../res/", $p)),
};
};
($i1:ident => $p1:expr, $($i2:ident => $p2:expr),+) => {
icons_consts! { $i1 => $p1 }
icons_consts! { $($i2 => $p2),+ }
}
}
macro_rules! icons_map {
($($i:ident => $p:expr),+) => {
pub const ICONS_MAP: phf::Map<&'static str, &'static Icon> = phf::phf_map! {
$($p => &icons::$i),+
};
}
}
macro_rules! icons {
($($i:ident => $p:expr),+) => {
pub mod icons {
use super::Icon;
icons_consts! {
$($i => $p),+
}
}
icons_map! {
$($i => $p),+
}
}
}
icons! {
NOTIFICATIONS => "notifications.svg",
NOTIFICATIONS_SOME => "notifications-some.svg",
PERSON => "person.svg",
UPVOTE => "upvote.svg",
UPVOTED => "upvoted.svg"
}
pub use icons::*;
|