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
#[used]
#[link_section = ".rust-audit-dep-list"]
static AUDITABLE_VERSION_INFO: [u8; include_bytes!(concat!(
env!("OUT_DIR"),
"/Cargo.lock.annotated"
))
.len()] = *include_bytes!(concat!(env!("OUT_DIR"), "/Cargo.lock.annotated"));
#[inline]
pub fn version_info() -> &'static str {
let _ = VERIFIED_UTF8;
unsafe { std::str::from_utf8_unchecked(&AUDITABLE_VERSION_INFO) }
}
static VERIFIED_UTF8: () = {
let data_to_verify: &[u8] = &AUDITABLE_VERSION_INFO;
let data_as_valid_string: &str =
include_str!(concat!(env!("OUT_DIR"), "/Cargo.lock.annotated"));
if !slices_are_equal(data_to_verify, data_as_valid_string.as_bytes()) {
fail_build_on_invalid_utf8_in_Cargo_toml();
}
};
const fn slices_are_equal(a: &[u8], b: &[u8]) -> bool {
if a.len() != b.len() {
return false;
};
let mut i = 0;
while i < a.len() {
if a[i] != b[i] {
return false;
}
i += 1;
}
true
}
#[allow(unconditional_panic)]
#[allow(non_snake_case)]
const fn fail_build_on_invalid_utf8_in_Cargo_toml() {
[()][1337];
}