Macro include_value
macro_rules! include_value {
($file:expr $(,)?) => { ... };
}
Includes a file and safely transmutes it to a value of an arbitrary type.
The file will be included as a byte array, [u8; N], which will be
transmuted to another type, T. T is inferred from the calling context,
and must implement FromBytes.
The file is located relative to the current file (similarly to how modules
are found). The provided path is interpreted in a platform-specific way at
compile time. So, for instance, an invocation with a Windows path containing
backslashes \ would not compile correctly on Unix.
include_value! is ignorant of byte order. For byte order-aware types, see
the byteorder module.
Examples
Assume there are two files in the same directory with the following contents:
File data (no trailing newline):
abcd
File main.rs:
use include_value;
#
Use in const contexts
This macro can be invoked in const contexts.