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
#[macro_use] extern crate proc_macro_hack;
extern crate syn;
extern crate hexf_parse;
proc_macro_expr_impl! {
#[doc(hidden)]
pub fn hexf32_impl(input: &str) -> String {
let lit = syn::parse::string(input).expect("hexf32! requires a single string literal");
match hexf_parse::parse_hexf32(&lit.value, true) {
Ok(v) => format!("{:?}f32", v),
Err(e) => panic!("hexf32! failed: {}", e),
}
}
}
proc_macro_expr_impl! {
#[doc(hidden)]
pub fn hexf64_impl(input: &str) -> String {
let lit = syn::parse::string(input).expect("hexf64! requires a single string literal");
match hexf_parse::parse_hexf64(&lit.value, true) {
Ok(v) => format!("{:?}f64", v),
Err(e) => panic!("hexf64! failed: {}", e),
}
}
}