const_anonymous_functions/
const_anon_functions.rs

1/// A macro for creating const anonymous functions.
2///
3/// The syntax is closure syntax but with a couple of caveats. Namely:
4/// - All types must be explicitly annotated, including the return type.
5/// - The body must always be surrounded by braces.
6///
7/// See the [module-level documentation](crate) for more info.
8#[macro_export]
9macro_rules! caf {
10	(|$($arg:tt: $arg_ty:ty),*| $(-> $return_ty:ty)? { $body:expr }) => {
11		{
12			const fn __anon_caf__($($arg: $arg_ty),*) $(-> $return_ty)? {
13				$body
14			}
15			__anon_caf__
16		}
17	};
18}