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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use syn::{self, Path};
#[derive(Debug, Clone, Copy, Default)]
pub struct Bindings {
pub no_std: bool,
}
impl Bindings {
pub fn string_ty(&self) -> Path {
syn::parse_str(if self.no_std {
"::alloc::string::String"
} else {
"::std::string::String"
})
.unwrap()
}
pub fn result_ty(&self) -> Path {
syn::parse_str(if self.no_std {
"::core::result::Result"
} else {
"::std::result::Result"
})
.unwrap()
}
pub fn option_ty(&self) -> Path {
syn::parse_str(if self.no_std {
"::core::option::Option"
} else {
"::std::option::Option"
})
.unwrap()
}
pub fn phantom_data_ty(&self) -> Path {
syn::parse_str(if self.no_std {
"::core::marker::PhantomData"
} else {
"::std::marker::PhantomData"
})
.unwrap()
}
pub fn default_trait(&self) -> Path {
syn::parse_str(if self.no_std {
"::core::default::Default"
} else {
"::std::default::Default"
})
.unwrap()
}
pub fn clone_trait(&self) -> Path {
syn::parse_str(if self.no_std {
"::core::clone::Clone"
} else {
"::std::clone::Clone"
})
.unwrap()
}
#[allow(clippy::wrong_self_convention)]
pub fn into_trait(&self) -> Path {
syn::parse_str(if self.no_std {
"::core::convert::Into"
} else {
"::std::convert::Into"
})
.unwrap()
}
pub fn try_into_trait(&self) -> Path {
syn::parse_str(if self.no_std {
"::core::convert::TryInto"
} else {
"::std::convert::TryInto"
})
.unwrap()
}
}