1/// Conditional compilation depending on whether Serde is built with support for
2/// 128-bit integers.
3///
4/// Data formats that wish to support Rust compiler versions older than 1.26
5/// (or targets that lack 128-bit integers) may place the i128 / u128 methods
6/// of their Serializer and Deserializer behind this macro.
7///
8/// Data formats that require a minimum Rust compiler version of at least 1.26,
9/// or do not target platforms that lack 128-bit integers, do not need to
10/// bother with this macro and may assume support for 128-bit integers.
11///
12/// ```edition2021
13/// # use serde::__private::doc::Error;
14/// #
15/// # struct MySerializer;
16/// #
17/// use serde::{serde_if_integer128, Serializer};
18///
19/// impl Serializer for MySerializer {
20/// type Ok = ();
21/// type Error = Error;
22///
23/// fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error> {
24/// /* ... */
25/// # unimplemented!()
26/// }
27///
28/// /* ... */
29///
30/// serde_if_integer128! {
31/// fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error> {
32/// /* ... */
33/// # unimplemented!()
34/// }
35///
36/// fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error> {
37/// /* ... */
38/// # unimplemented!()
39/// }
40/// }
41/// #
42/// # serde::__serialize_unimplemented! {
43/// # bool i8 i16 i32 u8 u16 u32 u64 f32 f64 char str bytes none some
44/// # unit unit_struct unit_variant newtype_struct newtype_variant seq
45/// # tuple tuple_struct tuple_variant map struct struct_variant
46/// # }
47/// }
48/// ```
49///
50/// When Serde is built with support for 128-bit integers, this macro expands
51/// transparently into just the input tokens.
52///
53/// ```edition2021
54/// macro_rules! serde_if_integer128 {
55/// ($($tt:tt)*) => {
56/// $($tt)*
57/// };
58/// }
59/// ```
60///
61/// When built without support for 128-bit integers, this macro expands to
62/// nothing.
63///
64/// ```edition2021
65/// macro_rules! serde_if_integer128 {
66/// ($($tt:tt)*) => {};
67/// }
68/// ```
69#[cfg(not(no_integer128))]
70#[macro_export]
71macro_rules! serde_if_integer128 {
72 ($($tt:tt)*) => {
73 $($tt)*
74 };
75}
76
77#[cfg(no_integer128)]
78#[macro_export]
79#[doc(hidden)]
80macro_rules! serde_if_integer128 {
81 ($($tt:tt)*) => {};
82}
83