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
use super::State;
fn choose(list: &'static [Option<&'static str>]) -> &'static str {
list.iter()
.filter_map(|&x| x)
.find(|s| !s.is_empty() && !s.contains(char::is_control))
.unwrap_or(&"<unknown>")
}
lazy_static! {
pub(super) static ref NAME_STR: &'static str = choose(&[option_env!("CARGO_PKG_NAME")]);
pub(super) static ref VERSION_STR: &'static str = choose(&[
option_env!("IRC_BOT_RS_GIT_VERSION"),
option_env!("CARGO_PKG_VERSION"),
]);
pub(super) static ref HOMEPAGE_STR: &'static str = choose(&[option_env!("CARGO_PKG_HOMEPAGE")]);
pub(super) static ref BRIEF_CREDITS_STRING: String = format!(
"Built with <{url}> {ver}",
url = HOMEPAGE_STR.deref(),
ver = VERSION_STR.deref(),
);
}
impl State {
pub fn framework_crate_name(&self) -> &'static str {
&NAME_STR
}
pub fn framework_version_str(&self) -> &'static str {
&VERSION_STR
}
pub fn framework_homepage_url_str(&self) -> &'static str {
&HOMEPAGE_STR
}
}